How to Install Laravel on VPS Using Nginx (2026 Guide) 

Keyword: install Laravel on VPS 
Framework: Laravel 11+ 
Server: Ubuntu 22.04 / 24.04 
Web Server: Nginx 

Installing Laravel on a VPS using Nginx is the preferred setup for speed, security, and scalability. In this 2026 guide, you’ll learn step-by-step how to install Laravel on a VPS with Nginx, even if you’re a beginner. 

Why Install Laravel on a VPS? 

Using a VPS instead of shared hosting gives you: 

  • Full server control 
  • Better performance 
  • Higher security 
  • Ability to scale 
  • Optimized Nginx + PHP setup 

This is why most professional Laravel projects are deployed on a VPS. 

Server Requirements for Laravel (2026) 

Before you install Laravel on VPS, make sure your server has: 

  • Ubuntu 22.04 or 24.04 
  • PHP 8.2 or 8.3 
  • Nginx 
  • MySQL / MariaDB 
  • Composer 
  • Git 

Step 1: Connect to Your VPS 

Use SSH to connect: 

ssh root@your_server_ip 
 

Update your server: 

apt update && apt upgrade -y 
 

Step 2: Install Nginx 

apt install nginx -y 
 

Start and enable Nginx: 

systemctl start nginx 
systemctl enable nginx 
 

Check in browser: 

http://your_server_ip 
 

Step 3: Install PHP (Required Extensions) 

apt install php php-cli php-fpm php-mysql php-xml php-mbstring php-curl php-zip php-bcmath php-gd -y 
 

Check PHP version: 

php -v 
 

Step 4: Install Composer 

curl -sS https://getcomposer.org/installer | php 
mv composer.phar /usr/local/bin/composer 
 

Verify: 

composer –version 
 

Step 5: Install MySQL 

apt install mysql-server -y 
 

Secure MySQL: 

mysql_secure_installation 
 

Create database: 

CREATE DATABASE laravel_db; 
CREATE USER ‘laravel_user’@’localhost’ IDENTIFIED BY ‘password’; 
GRANT ALL PRIVILEGES ON laravel_db.* TO ‘laravel_user’@’localhost’; 
FLUSH PRIVILEGES; 
 

Step 6: Install Laravel on VPS 

See also  All Adobe Softwares Free Available 

Go to web directory: 

cd /var/www 
 

Install Laravel: 

composer create-project laravel/laravel laravel-app 
 

Set permissions: 

chown -R www-data:www-data /var/www/laravel-app 
chmod -R 775 /var/www/laravel-app/storage /var/www/laravel-app/bootstrap/cache 
 

Step 7: Configure Environment File 

cd /var/www/laravel-app 
cp .env.example .env 
php artisan key:generate 
 

Edit .env: 

APP_NAME=Laravel 
APP_ENV=production 
APP_URL=http://your_domain.com 
 
DB_DATABASE=laravel_db 
DB_USERNAME=laravel_user 
DB_PASSWORD=password 
 

Step 8: Configure Nginx for Laravel 

Create config file: 

nano /etc/nginx/sites-available/laravel 
 

Paste this: 

server { 
   listen 80; 
   server_name your_domain.com; 
 
   root /var/www/laravel-app/public; 
   index index.php; 
 
   location / { 
       try_files $uri $uri/ /index.php?$query_string; 
   } 
 
   location ~ \.php$ { 
       include snippets/fastcgi-php.conf; 
       fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; 
   } 
 
   location ~ /\.ht { 
       deny all; 
   } 

 

Enable site: 

ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/ 
nginx -t 
systemctl reload nginx 
 

Step 9: Fix Storage & Cache Permissions 

php artisan storage:link 
php artisan config:clear 
php artisan cache:clear 
 

Step 10: Access Laravel Application 

Open browser: 

http://your_domain.com 
 

Laravel is now successfully installed on your VPS using Nginx. 

Common Errors & Fixes 

1. 502 Bad Gateway 

  • Check PHP-FPM version 
  • Verify fastcgi_pass socket 

2. Permission Denied 

chown -R www-data:www-data /var/www/laravel-app 
 

SEO FAQs: Install Laravel on VPS 

Is Nginx better than Apache for Laravel? 

Yes. Nginx is faster, uses fewer resources, and is ideal for Laravel. 

Which PHP version is best for Laravel in 2026? 

PHP 8.2 or PHP 8.3. 

Can I install Laravel on VPS without a domain? 

Yes, using server IP. 

Final Thoughts 

If you want high performance Laravel hosting, learning how to install Laravel on VPS using Nginx is essential. This setup is perfect for production environments, SaaS apps, and enterprise projects

See also  Fix Laravel Migration Error: Common Issues & Solutions 2026

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top