Laravel 11 is the latest major version of the popular PHP framework, introducing a streamlined skeleton, the new Reverb WebSocket server, and improved Eloquent features. This guide deploys a Laravel 11 application with Nginx and PHP 8.3 on Ubuntu 24.04 LTS.

Tested and valid on:

  • Ubuntu 24.04 LTS

Prerequisites

  • Ubuntu 24.04 LTS server
  • Nginx, PHP 8.3-FPM, MySQL 8.0 installed
  • Composer installed
  • A domain name pointed to your server

Step 1 – Create a New Laravel 11 Project

Use Composer to create the project:

composer create-project laravel/laravel /var/www/myapp "^11.0"

Step 2 – Set Permissions

Grant Nginx write access to required directories:

sudo chown -R www-data:www-data /var/www/myapp
sudo chmod -R 755 /var/www/myapp
sudo chmod -R 775 /var/www/myapp/storage /var/www/myapp/bootstrap/cache

Step 3 – Configure the Environment File

Copy the example environment file and edit it:

cd /var/www/myapp
cp .env.example .env
php artisan key:generate

Update database credentials in .env:

nano .env

Set:

DB_DATABASE=myapp
DB_USERNAME=myuser
DB_PASSWORD=StrongPassword123!

Step 4 – Create the MySQL Database

Create the database:

sudo mysql -e "CREATE DATABASE myapp; CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'StrongPassword123!'; GRANT ALL ON myapp.* TO 'myuser'@'localhost'; FLUSH PRIVILEGES;"

Step 5 – Run Migrations

Create the initial database tables:

cd /var/www/myapp && php artisan migrate

Step 6 – Configure Nginx

Create an Nginx server block:

sudo nano /etc/nginx/sites-available/myapp

Add:

server {
    listen 80;
    server_name myapp.example.com;
    root /var/www/myapp/public;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ .php$ {
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Enable and reload:

sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Step 7 – Secure with SSL

Add HTTPS with Certbot:

sudo certbot --nginx -d myapp.example.com

Conclusion

Laravel 11 is now deployed on Ubuntu 24.04 LTS with Nginx and PHP 8.3. Run php artisan serve locally for development and use Nginx in production. Enable Laravel’s queue worker and scheduler for background tasks.