One server, one deploy, and for thirty seconds every visitor sees an error page. That is the default deploy on a single EC2 instance: you pull the new code, run migrations, restart PHP-FPM, and during that window the app is either half-updated or not running at all. You do not need a load balancer or a second server to fix this. With a release directory and a symlink, you can deploy to a single EC2 instance with no visible downtime at all. I have used this pattern on a production Laravel app running on one Ubuntu EC2 instance behind nginx, and it held up across dozens of deploys.
The release directory pattern
The core idea is simple: never deploy into the directory your web server is serving. Keep each release in its own timestamped folder, and point a symlink at the one that is live. The layout looks like this:
/var/www/app/
releases/
20261107-090000/
20261107-091000/
current -> releases/20261107-091000
shared/
.env
storage/
nginx serves from /var/www/app/current/public. A deploy means building the new release in a fresh folder, then flipping the symlink. The flip itself is one atomic filesystem operation, so no request ever sees a half-copied codebase. Anything that must survive across releases, such as the .env file and the storage directory, lives in shared and gets symlinked into each release.
A deploy script that flips the symlink
Write the steps down as a script and run the same script every time. A typical deploy on a single server looks like this:
RELEASE=/var/www/app/releases/$(date +%Y%m%d-%H%M%S)
git clone --depth 1 git@github.com:example/app.git "$RELEASE"
ln -s /var/www/app/shared/.env "$RELEASE/.env"
ln -s /var/www/app/shared/storage "$RELEASE/storage"
cd "$RELEASE" && composer install --no-dev --optimize-autoloader
php artisan config:cache
php artisan route:cache
php artisan migrate --force
ln -sfn "$RELEASE" /var/www/app/current
sudo systemctl reload php8.2-fpm
Two details matter here. First, ln -sfn replaces the symlink atomically: the -n flag stops ln from treating the existing symlink as a directory, which would create a broken link inside it instead of replacing it. Second, systemctl reload (not restart) tells PHP-FPM to gracefully reload its workers. In-flight requests finish on the old workers while new requests pick up the new code. If your PHP-FPM pool serves a 502 during a restart, the usual causes are the ones I covered in my post on nginx 502 Bad Gateway with PHP-FPM.
Run migrations before the switch, and keep them backward compatible
Notice the order in the script: migrations run before the symlink flip. That is deliberate. The new code will expect the new schema, so the schema has to be ready before any request reaches the new release. But there is a catch: during the window between the migration and the flip, the old code is still serving traffic against the new schema. That means every migration must be backward compatible with the code that is currently running.
In practice this means: add columns as nullable, never rename a column in one deploy, never drop a column the old code still reads. Renames and drops go in a separate deploy after the new code is live everywhere. This is the expand-and-contract pattern, and on a single server it is not optional. It is the whole reason the deploy is safe.
Queue workers need a restart too
Flipping the symlink does nothing for long-running processes. A queue worker started an hour ago is still running the old code from its own memory, and it will keep processing jobs with that code until it is restarted. Laravel makes this easy:
php artisan horizon:terminate
Run this after the flip. Horizon restarts its workers, and the new workers boot from the new release. If you use plain queue workers, the equivalent is php artisan queue:restart, which signals workers to exit after their current job. Either way, restart workers after every deploy or your jobs will silently run stale code. The same applies to any scheduled task: cron runs artisan schedule:run, which reads from the current symlink each minute, so it picks up the new release automatically.
Rolling back is one command
This pattern makes rollback boring, which is exactly what you want at 2 a.m. The previous release is still on disk, untouched. To roll back, point the symlink at it and reload PHP-FPM:
ln -sfn /var/www/app/releases/20261107-090000 /var/www/app/current
sudo systemctl reload php8.2-fpm
php artisan horizon:terminate
Keep three to five old releases and delete the rest, or the disk will fill up over months of deploys. A one-line cleanup at the end of the deploy script does it: keep the newest five directories in releases and remove the older ones. Database migrations are the one thing a symlink flip cannot roll back, which is another reason to keep them backward compatible and additive.
What this does not solve
Be honest about the limits. This is still one server. If the instance itself goes down, the site goes down. A long-running request that started before the flip finishes on the old code, which is fine, but a deploy during a traffic spike still competes with live traffic for CPU. And if a migration locks a table on a large production database, the deploy will stall no matter how clean the symlink dance is. Run heavy migrations in a quiet window, or use concurrent index builds. Zero downtime here means zero downtime from the deploy itself, not from the infrastructure underneath it.
Takeaway
Zero-downtime deploys on a single EC2 instance come down to three habits: build each release in its own directory, switch to it with one atomic symlink flip, and keep every migration backward compatible with the code that is still running. Add a graceful PHP-FPM reload and a queue worker restart, and the whole deploy becomes a script you can run without warning anyone. Start with the directory layout and the script above, deploy it once on a staging instance first, and watch the logs during the flip. When nothing errors, you have a deploy process you can trust.