HowTo: Use a Custom Virtual Host Template with zs-client


This article is also available at our new Knowledge Base: HowTo: Use a Custom Virtual Host Template with zs-client

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
Note: The virtual host template file must be present locally on the server where you run the command.