Back to Homepage

Laravel 10 on Nginx running Ubuntu 23.10

4 min read


Server Ubuntu Laravel Nginx
Laravel 10 on Nginx running Ubuntu 23.10

This guide provides a thorough walkthrough on installing Laravel 10 on a Nginx server running Ubuntu 23.10. With real-time examples, you will be well on your way to setting up and exploring the new functionalities Laravel 10 has to offer.


  • A server running Ubuntu 23.10

  • Basic knowledge of terminal operations

  • Familiarity with Nginx and its configurations

Step 1: Updating Your System

Before diving into the installation process, it's crucial to ensure your system is up-to-date. Execute the following commands in your terminal:

sudo apt update && sudo apt upgrade

Step 2: Installing Nginx

If you don’t have Nginx installed already, install it by running the following command:

sudo apt install nginx

Once installed, start Nginx and enable it to run at boot:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 3: Installing PHP

Laravel is a PHP framework, hence some important modules are required for the installation of PHP. Install PHP and its essential extensions:

sudo apt install php php-cli php-mbstring unzip curl php-xml php-fpm

Step 4: Configuring Nginx for Laravel

Now, create a new Nginx server block file for your Laravel project:

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

Paste the following configuration, adjusting the server_name and root directives to match your domain and project directory:

server {
    listen 80;
    root /var/www/laravel/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.php index.htm index.html;

    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/laravel.error.log error;

    sendfile off;

    client_max_body_size 100m;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;

    location ~ /\.(?!well-known).* {
        deny all;

Save and close the file. Now, create a symbolic link to the sites-enabled directory to activate the server block:


sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/

Step 5: Installing Composer and Laravel

Composer, a dependency manager for PHP, is necessary for installing Laravel. If you haven’t installed Composer already, download and install it using the following commands:

cd ~

curl -sS -o /tmp/composer-setup.php

HASH=`curl -sS`

php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer

Now, install Laravel using Composer:

composer create-project laravel/laravel mysite "10.*"

Replace "mysite" with your desired project name.

Step 6: Setting Up File Permissions

Ensure that the storage and bootstrap/cache directories are writable:

sudo chmod -R 775 /var/www/laravel/storage
sudo chmod -R 775 /var/www/laravel/bootstrap/cache

Now we need to give the web server user write access to the storage and cache folders, where Laravel stores application-generated files:

sudo chown -R www-data.www-data /var/www/laravel/storage
sudo chown -R www-data.www-data /var/www/laravel/bootstrap/cache

Step 7: Finalizing the Installation

Now that all components are in place, test your Laravel installation by restarting Nginx:

sudo systemctl restart nginx

Navigate to your domain in your web browser. You should now see the default Laravel landing page, confirming the successful installation of Laravel 10 on your Nginx server running Ubuntu 23.10.


With Laravel 10 now installed on your Nginx server, you are all set to commence building robust, modern web applications. This guide has equipped you with the fundamental steps and examples to ensure a smooth installation process. As you delve deeper into Laravel, the extensive community and resources available will be your companions in exploring and mastering this elegant PHP framework.

Please remember to take a look at common issue livewire users faces when working on nginx server such as livewire.js not found.

Follow @LaravelSage on X → Follow @LaravelSage on Facebook →
Aniket Singh

Aniket Singh

View All Articles

Full-stack developer with a knack for Merging creativity with technical expertise for standout solutions.

Related Articles

data_forget Helper for Laravel

data_forget Helper for Laravel

Since Laravel version 10.15, there is a new utility function called data_forget that allows you to remove keys from an array or object using a "dot" notation.

Laravel Tenant Application with Tenancy

Laravel Tenant Application with Tenancy

You can make your Laravel app multi-tenant using the Tenancy for Laravel Tenant package. This tenancy package lets you make any Laravel application multi-tenant without rewriting it.

Top Laravel Packages for Building Powerful Applications

Top Laravel Packages for Building Powerful Applications

Are you ready to take your Laravel skills to the next level and build extraordinary applications? Look no further! In this blog post, we will unveil a treasure trove of top packages that will revolutionize your development process.

Subscribe for 20+ new Laravel tutorials every week

You can unsubscribe at any time. You'll also get -20% off my courses!

© 2024


Laravel Sage

   |    Privacy Policy