If you’ve ever tried deploying a Laravel application to a fresh Linux server, you know the struggle. Hours spent installing PHP, configuring Nginx, setting up databases, dealing with permissions, and finally adding SSL — only to realize something still doesn’t work.
It’s boring, time-consuming, and error-prone.
That’s why I built setup_laravel
, a one-paste bash script that automates the entire Laravel deployment process. Whether you’re a solo developer, an agency shipping multiple apps, or someone just learning server management, this script makes Laravel deployment fast, secure, and painless.
In this guide, you’ll learn:
-
Why
setup_laravel
saves hours of setup time -
The key features (Nginx, PHP, SSL, MySQL/PostgreSQL, caching, etc.)
-
Step-by-step instructions for your first deployment
-
How to add extra domains later with the included domain manager script
Why Deployments Are Painful (and How setup_laravel
Fixes It)
Typical Laravel deployment involves:
-
Installing Nginx, PHP, and configuring OPcache manually
-
Choosing and securing a database (MySQL or PostgreSQL)
-
Generating passwords and hardening the database
-
Cloning your Laravel repo, setting permissions, running
composer install
-
Configuring Nginx for SSL with Let’s Encrypt
-
Debugging small issues that waste hours
With setup_laravel
, all of this happens automatically.
👉 You run one command. The script installs everything, optimizes Laravel, configures Nginx, and even sets up HTTPS with Certbot. You get a working Laravel app live on your domain without lifting a finger.
Features of setup_laravel
Here’s what makes the script powerful:
-
Nginx + PHP (8.4 by default) with recommended OPcache settings
-
Database setup: MySQL or PostgreSQL, secured with strong random passwords
-
Optional caching with Memcached
-
Composer install with optimized autoloader and config caching
-
Nginx best practices: gzip, asset caching, secure defaults
-
Automatic SSL using Let’s Encrypt (no manual certificate setup)
-
Interactive mode for beginners, or non-interactive mode for automation
-
Domain confirmation step ensures DNS records are in place before SSL
-
Future-ready: Optional GitHub push support coming soon
Prerequisites
Before running the script, make sure you have:
-
An Ubuntu (or similar) server with root (sudo) access
-
An open SSH port to connect to the server
-
A domain name pointing to your server’s IP address
Your First Laravel Deployment with setup_laravel
Step 1: Copy the Script
SSH into your server and download the script:
wget https://raw.githubusercontent.com/theafolayan/setup-laravel/main/setup_laravel_nginx_ssl.sh
Step 2: Make It Executable
Step 3: Run the Script
Interactive mode (good for first-timers):
sudo ./setup_laravel_nginx_ssl.sh
Non-interactive example (ideal for automation pipelines):
💡 Tip: Use --dry-run
to preview what the script will do without making changes.
Automatic SSL Setup
Once the script finishes, Let’s Encrypt will handle SSL certificates for your domain. Just make sure your DNS A record points correctly to your server before running. Nginx will then be fully configured for HTTPS.
Adding Extra Domains
Need to point multiple domains to your Laravel app? Use the included manage_domains.sh
script.
wget https://raw.githubusercontent.com/theafolayan/setup-laravel/main/manage_domains.sh
chmod +x manage_domains.sh
sudo ./manage_domains.sh
The script automatically updates Nginx and sets up SSL for each new domain.
Conclusion
Deploying Laravel apps no longer has to be a frustrating chore. With setup_laravel
, you get a production-ready environment in minutes — PHP, Nginx, database, caching, SSL, and Laravel optimizations all included.
👉 Stop wasting time on repetitive setup.
👉 Start shipping faster.
Check out the GitHub repo here and try it on your next project.