Laravel runs well on a single VPS, and you get full control over PHP versions, workers and caching that shared hosting cannot offer. A correct production setup needs a few things that local development hides: PHP-FPM tuned for your memory, the web root pointing at public/ only, correct file permissions, cached configuration, and long-running queue workers that restart cleanly on deploy. This guide covers each of them on Ubuntu 24.04.
Step 1: Check PHP Version Requirements
Recent Laravel releases require PHP 8.2 or newer. Ubuntu 24.04 ships PHP 8.3 in its repositories, which is suitable. Ubuntu 22.04 ships PHP 8.1, which is too old for current Laravel; on that release, use a third-party PHP repository or upgrade the OS. Always confirm the requirement for your Laravel version in its upgrade guide.
Step 2: Install Nginx, PHP-FPM and Extensions
sudo apt update
sudo apt install -y nginx git unzip \
php8.3-fpm php8.3-cli php8.3-mbstring php8.3-xml php8.3-curl \
php8.3-zip php8.3-bcmath php8.3-intl php8.3-mysql php8.3-redis
php -v
Use php8.3-pgsql instead of php8.3-mysql for PostgreSQL. Install Composer from the official installer (verify the installer hash shown on getcomposer.org) or from the distribution package composer.
Install your database (for example sudo apt install -y mysql-server or mariadb-server), create a database and a user with a strong password, and keep it bound to localhost.
Step 3: Deploy the Application
sudo mkdir -p /var/www/app
sudo chown $USER:www-data /var/www/app
git clone https://github.com/your-org/app.git /var/www/app
cd /var/www/app
composer install --no-dev --optimize-autoloader
cp .env.example .env
php artisan key:generate
Edit .env for production:
APP_ENV=production
APP_DEBUG=false
APP_URL=https://example.com
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=app
DB_USERNAME=app
DB_PASSWORD=use-a-long-random-password
CACHE_STORE=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
APP_DEBUG=false is essential: debug pages expose environment variables, including database passwords. Restrict the file: chmod 640 .env, owned by your deploy user with group www-data. Variable names change between Laravel versions (for example CACHE_DRIVER became CACHE_STORE), so copy names from your own .env.example.
Step 4: Set File Permissions
PHP-FPM runs as www-data. It must write to storage/ and bootstrap/cache/, and should only read everything else:
cd /var/www/app
sudo chown -R $USER:www-data .
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
chmod 640 .env
Never use chmod -R 777. It lets any process on the server modify your code.
Step 5: Migrate and Cache
php artisan migrate --force
php artisan storage:link
php artisan config:cache
php artisan route:cache
php artisan view:cache
After config:cache, Laravel no longer reads .env at runtime, and env() calls outside config files return null. Read environment values only inside config/*.php and use config() in your code. Re-run the cache commands after every deploy.
Step 6: Configure Nginx
This configuration follows the one in Laravel's deployment documentation. Create /etc/nginx/sites-available/app:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/app/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
client_max_body_size 20m;
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; }
error_page 404 /index.php;
location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header X-Powered-By;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
sudo ln -s /etc/nginx/sites-available/app /etc/nginx/sites-enabled/
sudo rm -f /etc/nginx/sites-enabled/default
sudo nginx -t && sudo systemctl reload nginx
Two details matter for security. The root points at public/, so .env, vendor/ and storage/ can never be downloaded. Only index.php is passed to PHP, so an uploaded .php file elsewhere cannot execute.
Step 7: Tune PHP-FPM and OPcache
The pool file is /etc/php/8.3/fpm/pool.d/www.conf. The key setting is pm.max_children, which caps concurrent PHP processes and therefore memory:
pm = dynamic
pm.max_children = 20
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6
pm.max_requests = 500
Estimate it as RAM you can give PHP ÷ average memory per child. Check real usage with ps -o rss= -C php-fpm8.3 | awk '{s+=$1} END {print s/NR/1024 " MB"}'. On an 8 GB server that also runs MySQL and Redis, 4–5 GB for PHP at roughly 60 MB per child gives about 70 children; start lower and raise it while watching free -h.
OPcache is enabled by default in PHP-FPM. For production, in /etc/php/8.3/fpm/conf.d/10-opcache.ini set opcache.memory_consumption=256 and opcache.validate_timestamps=0, then reload PHP-FPM on each deploy so new code is picked up:
sudo systemctl reload php8.3-fpm
Step 8: Run Queue Workers with systemd
Queue workers are long-running processes, so supervise them. Create /etc/systemd/system/laravel-worker@.service:
[Unit]
Description=Laravel queue worker %i
After=network.target redis-server.service mysql.service
[Service]
User=www-data
Group=www-data
WorkingDirectory=/var/www/app
ExecStart=/usr/bin/php artisan queue:work --sleep=3 --tries=3 --max-time=3600
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now laravel-worker@1 laravel-worker@2
Workers keep your code in memory, so they must restart after a deploy. php artisan queue:restart tells them to exit after finishing the current job, and systemd starts fresh ones. Supervisor is a common alternative to systemd and is what Laravel's documentation uses; either is fine. Laravel Horizon is a good option if you use Redis queues heavily.
Step 9: Enable the Scheduler
Laravel's scheduler needs a single cron entry that runs every minute:
sudo crontab -u www-data -e
* * * * * cd /var/www/app && /usr/bin/php artisan schedule:run >> /dev/null 2>&1
The individual tasks and their timing live in your code. Our cron guide explains why absolute paths matter here.
Step 10: Enable HTTPS
sudo ufw allow 'Nginx Full'
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx -d example.com -d www.example.com
Behind a proxy or load balancer, configure Laravel's trusted proxies so generated URLs use https. With Nginx on the same server terminating TLS, PHP receives HTTPS=on via fastcgi_params and no extra setup is needed.
A Repeatable Deploy Script
#!/usr/bin/env bash
set -euo pipefail
cd /var/www/app
php artisan down --retry=60
git pull --ff-only
composer install --no-dev --optimize-autoloader --no-interaction
php artisan migrate --force
php artisan config:cache && php artisan route:cache && php artisan view:cache
sudo systemctl reload php8.3-fpm
php artisan queue:restart
php artisan up
php artisan down shows a maintenance page during the deploy. For true zero downtime, deploy each release into its own directory and switch a current symlink, which is what tools such as Deployer and Envoyer automate.
SkyRainCloud Plans for This Workload
PHP-FPM memory is the main sizing factor: each child process typically uses 30–80 MB. A Laravel app with MySQL and Redis fits 2 vCores / 8 GB; busy stores, multiple queue workers or several apps on one server need the 4 vCore / 16 GB tier.
Intel Xeon Platinum 8269CY VPS
KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — Intel | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Business websites, small apps, scheduled jobs and bots | Order |
| VPS 2 — Intel | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,169/month | Business software, mid-size databases, several sites on one server | Check stock |
| VPS 3 — Intel | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,249/month | ERP/CRM stacks, heavier databases, multiple production apps | Check stock |
| VPS 4 — Intel | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,299/month | High-memory workloads and consolidated production servers | Check stock |
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — AMD | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Websites, small APIs, bots, staging and VPN servers | Order |
| VPS 2 — AMD | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,299/month | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| VPS 3 — AMD | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,499/month | Production databases, high-traffic sites, multi-container apps | Order |
| VPS 4 — AMD | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,899/month | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| 500 error with no details | Read storage/logs/laravel.log and /var/log/nginx/error.log; often permissions on storage/ |
| "Permission denied" writing logs or cache | Re-apply group www-data and ug+rwx on storage and bootstrap/cache |
| 502 Bad Gateway | PHP-FPM stopped or wrong socket path; systemctl status php8.3-fpm and check fastcgi_pass |
| Config changes not applied | Re-run php artisan config:cache |
| Jobs run old code | Run php artisan queue:restart after deploying |
| 404 on every route except / | Missing try_files ... /index.php?$query_string in Nginx |
Frequently Asked Questions
Which PHP version do I need for Laravel?
Should I use Nginx or Apache for Laravel?
.htaccess file Laravel ships in public/.Why must the web root point to the public folder?
public/ is meant to be web-accessible. Pointing the root at the project directory would expose .env, source code and vendor/ to anyone who guesses the path.What permissions does Laravel need?
www-data) needs write access to storage/ and bootstrap/cache/ only. Everything else should be readable but not writable by it. Never use 777.How do I run Laravel queues in production?
php artisan queue:work under systemd or Supervisor so it restarts automatically, and call php artisan queue:restart after each deploy so workers load the new code.How do I set up the Laravel scheduler on a VPS?
* * * * * cd /var/www/app && php artisan schedule:run >> /dev/null 2>&1. Laravel decides which tasks are due each minute.Why does env() return null in production?
php artisan config:cache, the .env file is no longer loaded. Only call env() inside config files and read values with config() in application code.How should I size pm.max_children?
ps). Leave room for the database, Redis and the OS. Too high a value causes swapping; too low causes requests to queue.