Setup Laravel
Setup Laravel
This example installs a current Laravel 11 or 12 application inside the Devilbox PHP container and serves public/ through the standard Devilbox htdocs document root.
Overview
| Project name | Container path | Database | TLD_SUFFIX | Project URL |
|---|---|---|---|---|
my-laravel | /shared/httpd/my-laravel | my_laravel | lvh.me | http://my-laravel.lvh.me / https://my-laravel.lvh.me |
Inside the container, projects are in /shared/httpd/; on the host, they are under ./data/www/.
Prerequisites
- Devilbox with PHP 8.3 or PHP 8.4 available from
env-example. - Composer available in the PHP container.
- HTTPD, MySQL, and Bind services.
Start the stack:
./dvl.sh up php httpd mysql bindWalk through
It will be ready in eight steps:
- Enter the PHP container.
- Create a new virtual host directory.
- Install Laravel.
- Link
public/tohtdocs. - Add a MySQL database.
- Configure
.env. - Verify DNS.
- Open the project.
1. Enter the PHP container
./dvl.sh shell php832. Create the vhost directory
mkdir -p /shared/httpd/my-laravelcd /shared/httpd/my-laravel3. Install Laravel
For Laravel 11:
composer create-project laravel/laravel:^11.0 laravel-projectFor Laravel 12 on a compatible PHP runtime:
composer create-project laravel/laravel:^12.0 laravel-projectExpected structure:
tree -L 1.└── laravel-project4. Link the webroot
ln -s laravel-project/public htdocs5. Add the MySQL database
mysql -u root -h 127.0.0.1 -p -e 'CREATE DATABASE my_laravel CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'6. Configure Laravel
Edit laravel-project/.env:
APP_URL=http://my-laravel.lvh.meDB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=my_laravelDB_USERNAME=rootDB_PASSWORD=Then generate the application key if Composer did not already do it:
cd laravel-projectphp artisan key:generate7. Verify DNS
my-laravel.lvh.me resolves to 127.0.0.1. Add a hosts-file record only for custom suffixes.
8. Open your browser
Visit http://my-laravel.lvh.me or https://my-laravel.lvh.me.
Next steps
- Run Artisan commands with
./dvl.sh exec "php artisan"from the Laravel project directory. - Use Adminer or phpMyAdmin from the Devilbox intranet to inspect
my_laravel. - Add Redis, queues, or mail services only when your app needs them.