ZDT Deployment for PHP
Zero-Downtime Deployment for PHP
Zero-Downtime Deployment for PHP uses timestamped application directories and a symbolic link to switch incoming requests to a newly deployed version only after the update has completed. The previous version continues serving existing sessions during the transition.
How Zero-Downtime Deployment Works
Each deployment creates a separate timestamped application directory. A symbolic link named ROOT points to the application version currently handling new requests. After the updated files are fully deployed, the symbolic link switches to the new directory.
ROOT symlink changes only after the new deployment is ready.Provider-dependent feature
The availability of Zero-Downtime Deployment depends on the hosting provider’s platform settings.
ZDT Deployment Workflow
Prepare a PHP environment
Create a new PHP environment or use an existing one. The documented example uses Apache PHP.

Enable zero-downtime deployment
Start application deployment and enable the Zero-Downtime Deployment option in the confirmation window.
For deployment through an archive or direct URL:

For deployment from a Git, SVN, or Bitbucket repository:

ROOT context is required
The ZDT option is active only for deployment to the ROOT context of a PHP application server. Other contexts use the classic deployment method.
- For VCS projects, the selected deployment mode is remembered for later automatic updates until changed manually.
- Avoid hard-coded absolute application paths because the timestamped directory name changes after every deployment.
- For the first archive or URL deployment over an existing application in the ROOT context, previous data is normally replaced by the new base installation.
Review the initial deployment
The first deployment creates a directory named in the ROOT_year.mm.dd-hh.mm.ss format and a ROOT symbolic link pointing to it.

Use SSH to inspect the symbolic link:
ls -l /var/www/webroot

Deploy an updated version
A second timestamped directory is created while the current version remains active. After unpacking completes, the ROOT symlink switches to the new release.

User-generated content
With archive or URL deployment, move user-generated content manually from the previous directory to the new version. With VCS deployment, tracked and untracked content is copied automatically; use .gitignore to exclude unnecessary files.
Manage later releases
For each later atomic deployment, the oldest version is removed and the newest timestamped directory is added. Normally, only the current and previous versions remain.

To keep an older release from automatic removal, rename its folder before starting the next deployment.

ZDT Implementation on PHP Servers
Apache PHP
Apache PHP uses the mod_realdoc module to manage symbolic-link switching. Its configuration is available under conf.d → mod_realdoc.conf.

The RealpathEvery parameter defines how long the symbolic-link path is cached and how often it is refreshed. The documented platform value is 2. Restart the application-server node after changing it, and avoid setting it too high because that can delay symlink switching.
NGINX PHP
NGINX PHP provides atomic deployment through built-in configuration rather than an additional module. The relevant settings are located at the end of conf → nginx.conf.

Atomic and Classic Deployment Comparison
The source documentation compares both methods using a basic WordPress installation and Apache JMeter, with requests sent continuously before, during, and shortly after redeployment.
Classic Archive Deployment

In the documented test, the classic method delivered an average response time of about 1.2 seconds but produced failed requests for approximately two seconds during deployment.
Zero-Downtime Deployment

The ZDT test kept the response time generally stable, with a slight temporary increase while deployment and request handling ran together, and recorded no failed requests during the test.
Expected Result
PHP application updates are deployed to a new timestamped directory while the active version continues serving users. After the update succeeds, the ROOT symlink switches to the new version without restarting the application server.
Important Notes
- ZDT works only for the
ROOTdeployment context. - Avoid hard-coded absolute application-directory paths.
- Archive and URL deployments may require manual transfer of user-generated content.
- VCS deployment copies tracked and untracked files; maintain an appropriate
.gitignore. - The platform normally retains only the current and previous application versions.
- Rename a version folder before the next deployment when it must be retained.
- Changing Apache
RealpathEveryrequires a node restart.
Common Issues and Solutions
RealpathEvery value and avoid an unnecessarily high cache duration.