Laravel VPS Deployment Guide: PHP-FPM, Nginx, Redis and Queue Workers
A production Laravel deployment on a VPS, step by step, following Laravel's own deployment guide.
A production Laravel deployment on a VPS needs Nginx in front of PHP-FPM, the framework's optimisation commands run on every deploy, Redis for cache, sessions and queues, queue workers kept alive by a process supervisor, and the scheduler run by cron. Laravel's deployment documentation covers the framework side. This guide adds the server side.
Prerequisites
- A KVM VPS with root access. VPS 4 (2 vCPU, 4 GB) suits a small app. VPS 8 (4 vCPU, 8 GB, ₹1,438) is the usual production start.
- A supported PHP version with the extensions Laravel requires.
- A domain pointing at the server.
Step 1: Nginx and PHP-FPM
server {
listen 80;
server_name app.example.com;
root /var/www/app/public;
index index.php;
location / { try_files $uri $uri/ /index.php?$query_string; }
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
location ~ /\.(?!well-known).* { deny all; }
}Point the web root at public, never at the project root. Add TLS once the site answers on port 80.
Step 2: size PHP-FPM
The PHP-FPM configuration manual explains the process manager settings. With pm = dynamic, set pm.max_children from memory: measure a worker's typical memory under load, then divide the memory you can spare by that figure. Too many children cause swapping. Too few cause requests to queue.
Step 3: deploy commands
composer install --no-dev --optimize-autoloader
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan migrate --forceLaravel's deployment guide recommends caching configuration, routes and views in production. Set APP_ENV=production and APP_DEBUG=false.
Step 4: Redis, queues and the scheduler
- Use Redis for cache, sessions and the queue connection.
- Run workers with
php artisan queue:workunder Supervisor or systemd so they restart on failure, and restart them on every deploy withphp artisan queue:restart. - For Redis queues with many jobs, Laravel Horizon adds a dashboard and worker balancing.
- Add one cron entry:
* * * * * php /var/www/app/artisan schedule:run.
Step 5: verify
- Load the site with debug off and confirm errors are logged, not shown.
- Dispatch a test job and confirm a worker processes it.
- Reboot and confirm workers and the scheduler return on their own.
Sizing
| Plan | vCPU | Memory | RAID NVMe | Transfer | Monthly |
|---|---|---|---|---|---|
| VPS 2 | 1 | 2 GB | 20 GB | 100 GB | ₹298 |
| VPS 4 | 2 | 4 GB | 40 GB | 200 GB | ₹596 |
| VPS 8 | 4 | 8 GB | 80 GB | 400 GB | ₹1,438 |
| VPS 16 | 6 | 16 GB | 160 GB | 800 GB | ₹2,399 |
| VPS 32 | 12 | 32 GB | 320 GB | 1,600 GB | ₹4,799 |
Monthly INR, excluding GST. All ten sizes, from 1 GB (₹149) to 128 GB (₹19,099), are on the VPSWala cloud VPS plans page. Every plan is KVM with RAID NVMe storage and full root access.
PHP request handling depends heavily on single-thread speed, so busy Laravel apps are a good candidate for the 9950X range, starting with 9950X VPS 16 at ₹2,399 per month.
Responsibilities
VPSWala plans are unmanaged unless you agree otherwise in writing: the host platform, network and provisioning are VPSWala's job, and everything inside the VM is yours. Per the terms of service, off-server backups, control-panel licences, Windows licensing, managed administration and extra IPv4 addresses are quoted separately, and any availability commitment applies only where it is written into your quotation or agreement.
Zero-downtime deploys
Deploy each release into its own directory, run Composer and the cache commands there, then switch a current symlink and reload PHP-FPM. If the new release fails, point the symlink back. Tools such as Deployer or Envoyer automate this pattern, but it is simple enough to script yourself.
Security checklist
- Keep the
.envfile outside the web root and readable only by the app user. - Run PHP-FPM as a dedicated user, not as root.
- Keep storage and cache directories writable by the app user only.
- Restrict SSH to key authentication and firewall everything except SSH, HTTP and HTTPS.
Keep logs in storage/logs rotated daily so a noisy error never fills the disk.
Frequently asked questions
Should MySQL run on the same VPS?
For small and medium apps, yes. Separate it once the database needs its own memory or you want independent scaling.
How many queue workers should I run?
Start with one or two per queue and watch how long jobs wait. Add workers when the wait time grows, and watch memory as you do.
Octane or PHP-FPM?
PHP-FPM is the simple, well-understood default. Laravel Octane can raise throughput but changes how state behaves between requests. Adopt it deliberately.
Sources
Not sure which size?
Send the stack, get a size.
Tell us the operating system, application stack, current traffic, database size and where it hurts today. You get a sizing recommendation, the matching plan and a price.
Related
Deploying Next.js SSR on a Linux VPS: Standalone Build, PM2 & Nginx Proxy
Learn how to deploy a server-rendered Next.js application on a Linux KVM VPS using standalone build artifacts, PM2 cluster management, and Nginx.
VPS Firewall Setup with UFW and iptables: Port Hardening & Lockout Prevention
A hands-on sysadmin guide to securing a Linux cloud VPS with UFW and iptables, implementing strict ingress filtering while preventing accidental connection loss.
VPS Hosting for Bhopal: Which VPSWala Node to Pick and How to Test It
A practical routing and workload sizing guide for developers and businesses in Bhopal to evaluate VPSWala cloud nodes and verify network path stability.