Setting up an Ubuntu Linux Server for Laravel
Configuring a Linux server for Laravel can feel like a hassle—especially if you’re doing it for the first time. We’ve been through the struggle a few times, so we thought we’d share the setup process we use to get our Laravel apps running smoothly on Ubuntu.
Let’s get started.
1. Create a New User for Laravel
Start by logging into your server via SSH as root:
Now add a new user:
Give the new user sudo privileges:
Check if the user was added:
Then switch to the new user:
2. Install and Configure NGINX
Update your system packages:
Install NGINX:
Start and enable NGINX:
Allow HTTP traffic through the firewall:
3. Install PHP and Required Extensions
Install PHP and extensions required by Laravel:
Check PHP version:
4. Install Composer (PHP Dependency Manager)
Check Composer version:
5. Deploy Your Laravel Project
Clone Your Repository
Make sure git is installed:
Clone your Laravel project:
Copy .env File
If you have an .env file from development or staging, copy it over:
Then update database credentials and any other relevant settings.
Install PHP Dependencies
Generate Application Key
Migrate the Database
Make sure your database is configured and accessible.
If you have seeders:
Link the Storage Folder
Set File Permissions
6. Configure NGINX for Laravel
Create a new site configuration:
Paste this sample config:
Enable the site:
7. Optional: Set Up SSL with Let’s Encrypt
If your domain is pointing to the server:
Follow the prompts to install a free SSL certificate.
Done!
Your Laravel app should now be up and running on your Ubuntu server.

