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 sudo
command.
Zend provides the following scripts:
- zendphp_credentials
- zendphp-vhost
- zendphp-switch
zendphp_credentials
The following is valid for hourly+annual or hourly+monthly cloud images only.
The script 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 update
for DEB-based distributions andyum update
for 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
The 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.
Use
zendphp-vhost (action) (vhost domain) (port) (options) (email)
Parameters
- action: One of:
info
,add
,remove
,chgname
, orchgport
. - 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.
Examples
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 webmaster@somedomain.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
zendphp-switch
The zendphp-switch script allows you to switch between ZendPHP versions.
Use
zendphp-switch (action) (version) (vhost domain)
Parameters
- action: One of:
to
,off
. - version: PHP version (currently possible: 7.2, 7.3, 7.4, 8.0, 8.1 or 8.2)
- vhost domain: Virtual host you want to switch the PHP version on.
Examples
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