Using ZendPHP cloud images
All ZendPHP cloud images set up a default virtual host located in the directory
/var/www. Users can upload a PHP application to that directory and immediately have a running web application.
Additionally, ZendPHP cloud images come with several scripts to allow you to switch PHP versions and manage virtual hosts and SSL details. These are all located in
/usr/local/bin and MUST be run as root or via the
Zend provides the following scripts:
zendphp_credentials (hourly+annual or hourly+monthly cloud images only)
zendphp_credentials does the following:
- On first invocation, this script requests credentials from the ZendPHP credentialing service. If successful, it then installs them such that your package manager uses them when retrieving ZendPHP packages. After a successful operation, run the command that updates your package manager's cache (e.g.,
apt-get updatefor DEB-based distributions and
yum updatefor RPM-based distributions).
- On subsequent invocations, it renews your credentials for a period of one month.
For Bring-Your-Own-License images, obtain and install credentials directly from Zend by Perforce. For hourly/monthly/annual images, you need to run the script during initial provisioning and once every 4 weeks thereafter via a cronjob.
If you need to use it manually, run
zendphp_credentials help at the command line.
zendphp-vhost script allows you to add, rename, or remove virtual hosts. The script also fetches and configures a TLS certificate for the vhost via the Let's Encrypt Certificate Authority (CA). If the query fails, the script uses the self-signed localhost certificate.
zendphp-vhost (action) (vhost domain) (port) (options) (email)
- action: One of:
- vhost domain: Domain for which to create, modify, or remove a virtual host.
- port: If set, configures the virtual host to this port; otherwise sets the port to the default (80).
- options: One of http or https. This option also configures the port for http or https. If set to https the script retrieves the certificate from Let's Encrypt.
- email: Webmaster e-mail. If not set, the script uses the default webmaster@localhost. Note: If you use the default e-mail, certbot (the Let's Encrypt client) prompts you for a valid e-mail address to ensure renewal notifications can be sent.
Show currently enabled vhosts:
$ zendphp-vhost info
Create new vhost (use default parameters):
$ zendphp-vhost add somehost.somedomain.com
Create new vhost (preconfigures port 443 and fetch certificate from Let's Encrypt CA):
$ zendphp-vhost add somehost.somedomain.com 443 https email@example.com
Change vhost name (also requests a new TLS certificate from Let's Encrypt and revokes/deletes the old one):
$ zendphp-vhost chgname somehost.somedomain.com someotherhost.somedomain.com
Change vhost port to non-secure (non-ssl enabled) port:
$ zendphp-vhost chgport somehost.somedomain.com 81 http
Change vhost port to secure (ssl) port (also runs certbot command to configure certificate):
$ zendphp-vhost chgport somehost.somedomain.com 444 https
Remove virtual host (also asks whether to preserve or delete the document root directory as well as configuration files, and asks to revoke/delete the previously installed certificate):
$ zendphp-vhost remove somehost.somedomain.com
The zendphp-switch script allows you to switch between ZendPHP versions.
zendphp-switch (action) (version) (vhost domain)
- action: One of:
- version: PHP version (currently possible: 5.6, 7.1, 7.2, 7.3, 7.4, or 8.0)
- vhost domain: Virtual host you want to switch the PHP version on.
Switch from current ZendPHP version to 7.4:
$ zendphp-switch to 7.4 somehost.somedomain.com
Switch ZendPHP 7.4 FPM process off:
zendphp-switch off 7.4