Applies To

Zend Server



While creating, editing or validating a Virtual Host using zs-client, if you need to include special parameters in the Virtual Host, you can use a custom Virtual Host template using the "--template" option. For example, to set Apache Environment, you can add "SetEnv APPLICATION_ENV" parameter to your custom template and use it in the zs-client command. See attached vhost_sample.tpl.


Depending on your environment, you need to use any one of the following Virtual Host templates:

Apache --> /usr/local/zend/share/vhost.tpl

Apache with SSL --> /usr/local/zend/share/vhost-ssl.tpl

NginX --> /usr/local/zend/share/vhost-nginx.tpl

NginX with SSL --> /usr/local/zend/share/vhost-nginx-ssl.tpl

You can create a copy of the template file (file extension must be ".tpl") and place it somewhere on your server, for example /root/vhost_templates. Then specify the absolute path to this template file in the zs-client command. Sample command to add a Virtual Host using zs-client vhostAdd:

# /usr/local/zend/bin/php zs-client.phar vhostAdd --name=samplevhost --port=80 --template=/root/vhost_templates/vhost_sample.tpl --forceCreation=true --zsurl=http://localhost:10081 --zskey=admin --zssecret=123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234



The virtual host template file must be present locally on the server where you run the command.

Sample Apache VHost Template
# Created by Zend Server

<VirtualHost *:${port}>

    DocumentRoot "${docroot}"
    <Directory "${docroot}">
        Options +Indexes +FollowSymLinks
        DirectoryIndex index.php
        Order allow,deny
        Allow from all
        AllowOverride All
        Require all granted

    SetEnv APPLICATION_ENV "development"
    ServerName ${vhost}:${port}
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    # include the folder containing the vhost aliases for zend server deployment
    IncludeOptional "${aliasdir}/*.conf"


  • No labels