Loading…
Loading…
Free tool · No sign-up
Paste in four details. Get the five files a single-server Laravel deploy actually needs — sized to your VPS, not copied from a tutorial.
Defaults come from production use on this author's own VPS — a Laravel SaaS, a store API and this blog — not from a roundup.
Everything runs in your browser — nothing you type is sent anywhere, stored, or logged. No sign-up, no email wall.
/etc/nginx/sites-available/laravel
# example.com — Laravel on nginx + PHP-FPM 8.3
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;
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 ~ \.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;
}
}
# SSL: run `sudo certbot --nginx -d example.com -d www.example.com` — certbot
# rewrites this block for 443 and adds the redirect; do not hand-edit
# the cert paths afterwards./etc/php/{version}/fpm/pool.d/www.conf
pm.max_children is sized from your RAM, not a magic number: floor((2048 − 512) / 70) = 21. 512 MB stays reserved for the OS + MySQL, ~70 MB per PHP child.
; /etc/php/8.3/fpm/pool.d/www.conf — Laravel pool
[www]
user = www-data
group = www-data
listen = /run/php/php8.3-fpm.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 21
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500/etc/supervisor/conf.d/{app}-worker.conf
Queue workers boot the app once. After every deploy, run php artisan queue:restart — or the workers keep processing jobs with the OLD code. Supervisor restarts the process; it does not reload your code.
; /etc/supervisor/conf.d/example-worker.conf
[program:example-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/app/artisan queue:work database --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=2
redirect_stderr=true
stdout_logfile=/var/www/app/storage/logs/worker.log
stopwaitsecs=3600run in order, every deploy
# Deploy checklist — example.com
cd /var/www/app
git pull origin main
composer install --no-dev --optimize-autoloader
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan storage:link
sudo chown -R www-data:www-data /var/www/app
sudo chmod -R 755 /var/www/app/storage /var/www/app/bootstrap/cache
php artisan queue:restart # <-- the step everyone forgets
sudo supervisorctl reread && sudo supervisorctl update
sudo systemctl reload php8.3-fpm nginx
# Scheduler — add to crontab (crontab -e):
* * * * * cd /var/www/app && php artisan schedule:run >> /dev/null 2>&1.env (placeholders only — never real secrets)
Generate APP_KEY per app with php artisan key:generate — never copy a key from a snippet, a tutorial, or another project.
APP_NAME="Example"
APP_ENV=production
APP_DEBUG=false
APP_URL=https://example.com
APP_KEY=base64:GENERATE_WITH_php_artisan_key_generate # never paste a real key here
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=example
DB_USERNAME=example
DB_PASSWORD=CHANGEME
QUEUE_CONNECTION=database
CACHE_STORE=database
SESSION_DRIVER=databaseThe generator assumes one server running Ubuntu 24.04 LTS with the ondrej/php PPA, nginx + PHP-FPM, and MySQL 8 (or MariaDB). The nginx block serves Laravel's public/ directory, denies dotfiles, and hides X-Powered-By.
pm.max_children is computed, not guessed: 512 MB stays reserved for the OS + MySQL, then each PHP child gets ~70 MB — floor((RAM − 512) / 70). On a 2 GB VPS that is 21 children. Queue workers are heavier: each queue:work process holds ~100–200 MB, so size the worker count to your RAM the same way.
Deliberately not covered: multi-server setups, Octane/Swoole, load balancers, and Redis Sentinel. This tool is for one server done right — if you need those, you need an architecture, not a config snippet.
Where this ran: the author's own VPS stack — the Veliq store API, the blog API behind this site, and a Messenger-automation SaaS — all Laravel backends on nginx + PHP-FPM + Supervisor.
Queue workers boot the app once and keep running. After every deploy, run php artisan queue:restart — it is in the checklist above for a reason. Supervisor restarts the process; it does not reload your code.
Not a magic number: each worker holds ~100–200 MB, and MySQL plus the OS already take their share. On a 2 GB box, 2–4 workers is the honest range — the generator defaults to 2 and lets you raise it if your RAM allows.
No. The database driver is fine to start with and is the generator's default. Move to Redis when your queue volume outgrows it — the generator outputs both, so switching is a one-line change.