MANUAL
Deploying a Laravel app
Putting your Laravel app online
Your app works on your laptop. Now it needs to run on a server so that others can use it. This is called deployment.
01
Step 1: Choose where your app will run
| Option | For whom | Please note |
|---|---|---|
| Managed platform (Laravel Cloud, or a PaaS that supports PHP) | You don’t want to manage servers | More expensive per month, but low maintenance |
| VPS with a management tool (e.g. Laravel Forge or Ploi on a VPS) | You want control but not the hassle | You pay for the VPS and the tool separately |
| Bare-metal VPS | You’re familiar with Linux | You’re responsible for updates and security |
| Shared hosting | Small websites with no queues | Often no SSH, no queue workers, outdated PHP versions |
For most small business apps, a managed platform or a VPS with a management tool is the best choice.
02
Step 2: Prepare the server
The server requires: the correct PHP version (the same as on your local machine), Composer, a database, and Node.js if you are building the front-end on the server.
Important: the web server must point to the public/ folder, not to your project’s root folder. Otherwise, anyone will be able to download your .env file.
03
Step 3: Set up the environment properly
Create a .env file on the server (see .env and environment variables) containing at least the following:
APP_ENV=production
APP_DEBUG=false
APP_URL=https://jouwdomein.nl
Generate a key once: php artisan key:generate. Never change it again.
04
Step 4: the deployment steps
These are the commands that run with every new version (an administration tool does this automatically):
git pull origin main
composer install --no-dev --optimize-autoloader
npm ci && npm run build
php artisan migrate --force
php artisan optimize
php artisan storage:link # alleen de eerste keer
php artisan queue:restart
The --force option with migrate is required in production, as Laravel would otherwise ask for confirmation. Make a backup of your database before running a migration.
05
Step 5: Background tasks
- Queue workers (sending emails, generating PDFs) must continue to run. On a VPS, you can manage this using Supervisor; managed platforms have a setting for this.
- Scheduled tasks: Add one cron job that runs
php artisan schedule:runevery minute.
06
Step 6: HTTPS and domain
Point your domain (DNS) to your server and obtain a free certificate via Let’s Encrypt. Most management tools allow you to do this with a single click. Ensure that APP_URL begins with https://.
07
Automatic deployment
Using GitHub Actions or your management tool’s deploy hook, your app will be updated automatically after every push to main. Run your tests first, and only deploy if they pass.
08
Errors after deployment
| What you see | Probable cause |
|---|---|
| 500 error | Check storage/logs/laravel.log; often caused by a missing .env value or directory permissions |
| 502 Bad Gateway | PHP-FPM is not running or the wrong version of PHP is being used |
| 503 | The app is still undergoing maintenance: php artisan up |
| Styles missing | npm run build not run or incorrect APP_URL |
| 419 in forms | Session/cookie settings or HTTPS configuration |
See also Understanding HTTP status codes and troubleshooting API errors.
09
Need help?
Would you like to have your app built in a reliable, low-maintenance way? This falls under Bespoke software and web applications. For websites: Web design and development.
10
Skills
- [Deploying with Laravel Cloud] (/nl/skills/deploying-to-cloud)
- [Deployment Pipeline Design] (/nl/skills/deployment-pipeline-design)
- [GitHub Actions Templates] (/nl/skills/github-actions-templates)
- [Laravel environment and config] (/nl/skills/laravel-env-config)
11
Related services
- [Maatwerk software en webapplicaties] (/nl/services#service-03)
- [Webdesign en -ontwikkeling] (/nl/services#service-01)