ZDT Deployment for PHP

Zero-Downtime Deployment for PHP

Zero-Downtime Deployment enables PHP applications to be updated without interrupting active user sessions or returning deployment-related errors. The platform prepares the new application version separately and switches incoming traffic only after deployment is successfully completed.

Zero-Downtime redeployment

How Zero-Downtime Deployment Works

Application redeployment can temporarily make a website unavailable while files are replaced. Traditional solutions often require extra servers, a load balancer, external deployment tools, and additional configuration. The platform provides an atomic deployment mechanism for PHP applications that avoids these requirements.

The mechanism is based on two core principles:

Separate application versions Every deployment is placed in a separate server directory whose name includes the creation date and time.
Symbolic link switching A symbolic link identifies the active version and is switched to the newly deployed directory only after the update is complete.
PHP zero-downtime deployment workflow
The existing version continues processing requests while the new version is deployed.

After the new application version is fully prepared, the symbolic link is switched instantly. New requests are routed to the updated version while existing sessions can finish on the previous one. This makes the update atomic and transparent to application users.

!

Availability

The availability of Zero-Downtime Deployment depends on the configuration provided by your hosting provider.

ZDT Deployment Workflow

1

Create a new PHP environment or use an existing one. Apache PHP is used in this example.

PHP environment wizard
Prepare a PHP environment for the application deployment.
2

Deploy the required application and enable the Enable zero-downtime deployment option in the deployment confirmation window.

The option is available for applications deployed from a local archive, a direct URL, or a version-control repository.

Deployment from an Archive or URL

Enable zero-downtime archive deployment
Enable Zero-Downtime Deployment before deploying the archive.
!

Existing ROOT application

During the first atomic deployment from an archive or URL to an existing ROOT context, the previous ROOT data is normally replaced by a clean deployment of the application package.

Deployment from Git or SVN

Enable zero-downtime Git deployment
Enable atomic deployment when adding a Git or SVN project.
!
  • The Zero-Downtime option is active only for the ROOT context of a PHP application server. Other contexts use classic deployment.
  • For VCS projects, the selected deployment mode is remembered and reused for future automatic updates until changed manually.
  • Avoid hard-coded absolute paths because each atomic deployment uses a new timestamped directory.
3

During the first deployment, the platform creates a directory named in the following format:

ROOT_year.mm.dd-hh.mm.ss

It also creates a special ROOT symbolic link that points to this directory.

First PHP application version deployed
The ROOT symbolic link and first timestamped application directory.

To view the symbolic link and its destination through SSH, run:

ls -l /var/www/webroot
ROOT symbolic link in SSH
The command output shows the current symbolic-link destination.
4

During the next deployment, a second timestamped directory is created. The current application remains online while the new files are prepared.

After unpacking or updating is complete, the ROOT symbolic link switches to the new directory. New requests use the updated version, while the previous directory remains available for sessions that began before the switch.

Second PHP application version deployed
The current and previous versions are stored in separate timestamped folders.
!

User-generated content

For archive or URL deployments, user-generated content inside the previous application directory must be moved manually to the new directory when required.

For VCS deployments, tracked and untracked application files are copied automatically. Use a properly configured .gitignore file to avoid copying unnecessary content during repeated updates.

5

Future atomic deployments follow the same process. The platform creates a new timestamped directory and removes the oldest application directory.

Third PHP application deployment
Only the latest and previous application versions are retained automatically.

By default, the application server keeps two deployed versions: the active version and the preceding one. This limits additional disk-space consumption. An older version can also be removed manually when it is no longer required.

Preserve a specific version

Rename a timestamped application directory before the next deployment to prevent that directory from being removed automatically.

Renamed PHP application version
Rename a version directory to keep it as a manual backup.

The complete process is automated and does not require an application-server restart. The deployment is performed in a soft mode, so the application continues serving users throughout the update.

ZDT Implementation on PHP Servers

Apache PHP

Apache PHP implements symbolic-link switching through the mod_realdoc module. Its configuration is available in:

conf.d/mod_realdoc.conf
Apache mod_realdoc configuration
Apache Zero-Downtime Deployment configuration in mod_realdoc.conf.

RealpathEvery parameter

The RealpathEvery value controls how long the symbolic-link path is cached and how frequently it is refreshed. The platform commonly sets this value to 2 seconds so deployment and switching can finish before requests are redirected.

A custom value can be applied, but the application-server node must be restarted. Avoid excessively high values because they delay symbolic-link switching.

NGINX PHP

NGINX PHP provides atomic deployment through built-in functionality and does not require an additional module. The relevant settings are located near the end of:

conf/nginx.conf
NGINX zero-downtime configuration
Built-in Zero-Downtime Deployment settings in nginx.conf.

Classic and Atomic Deployment Comparison

The original test used a basic WordPress installation and Apache JMeter to send continuous concurrent requests before, during, and after redeployment. The graphs compare successful requests, errors, and response time.

Archive Deployment

With classic archive deployment, the application generally responds quickly before and after the update, but failed requests can occur while the previous package is replaced. In the documented test, errors were visible for approximately two seconds.

Classic archive deployment test
Classic archive deployment shows a temporary increase in failed requests.

With Zero-Downtime Deployment, response time remains stable with only a small temporary increase while the update runs in parallel. The test shows no failed requests during deployment.

Zero-downtime archive deployment test
Atomic archive deployment processes all requests without errors.

VCS Deployment

Classic Git or SVN deployment updates the changed files in the active application directory. When files currently used by the application are replaced, temporary downtime and failed requests can occur. The documented test recorded an interruption lasting nearly four seconds.

Classic VCS deployment test
Classic VCS deployment can produce errors when active files are updated.

Atomic VCS deployment keeps the active version online while the project is copied and updated in a separate directory. Response time may increase slightly, but incoming requests continue to be processed successfully.

Zero-downtime VCS deployment test
Zero-Downtime VCS deployment completes without failed requests.

Benefits and Conclusion

No additional infrastructure No extra application servers, load balancers, or external deployment tools are required. Only enough disk space for the active and previous application versions is needed.
Simple deployment process The workflow remains nearly identical to classic deployment and does not require additional manual operations.
No deployment delay Atomic deployment normally requires approximately the same processing time as the corresponding classic deployment.
Error-free updates The active application remains available while the new version is prepared, preventing failed requests during redeployment.

Expected result

The updated PHP application version is deployed in a separate directory, the ROOT symbolic link switches to it after successful deployment, and users continue accessing the application without interruption.