Manage your ZendPHP installation using zendphpctl
The zendphpctl utility is a Linux script for installing, managing, and updating your ZendPHP installation. It is recommended because it supports management tasks from registering the ZendPHP package repository, to installing and configuring multiple PHP versions, to enabling and configuring PHP-FPM, to installing PHP extensions.
Supported operating systems
The script is supported on the following operating system:
-
Linux x86-64
-
Linux arm64
-
IBM i with Open Source Environment installed
Installation instructions
To install the zendphpctl script:
-
Download the
zendphpctl
script and its signature from our repository:Copy$ curl -L https://repos.zend.com/zendphp/zendphpctl -o zendphpctl
$ curl -L https://repos.zend.com/zendphp/zendphpctl.sig -o zendphpctl.sig -
Validate the signature:
Copyecho "$(cat zendphpctl.sig) zendphpctl" | sha256sum --check
-
If the signature is valid, remove the signature file, then set permissions for the script:
Copy$ rm zendphpctl.sig
$ chmod +x zendphpctl
You can either use the script immediately from its current location, or place it somewhere in your $PATH
(For example, /usr/local/bin
).
Below is a breakdown of the various commands, each with their own set of options. For any of the options below, you can provide the '--help' flag to see the help for that specific command.
Work with the ZendPHP package repository
Install the ZendPHP package repository (repo install)
The 'repo install' command lets you install the ZendPHP package repository on your system. You can also provide your credentials to allow immediate access to LTS editions of ZendPHP. If you specify your credentials, you must provide both the '--account' and '--password' flags.
zendphpctl repo-install
; please update your scripts to use the new command name.For example:
zendphpctl repo install
Where [options] are any of the following:
Name | Short name | Description |
---|---|---|
--account <account> | (Optional) Account or order identifier associated with your credentials | |
--password <password> | (Optional) Password associated with your credentials |
Example 1:
zendphpctl repo install
Example 2:
zendphpctl repo install --account ORDER_ID --password PASSWORD
Provide credentials for the ZendPHP package repository (repo credentials)
The 'repo credentials' command lets you provide credentials for the ZendPHP package repository on your system, which allows access to LTS editions. When running this option, you must specify both the '--account' and '--password' options.
zendphpctl repo-credentials
; please update to use the new command name.For example:
zendphpctl repo credentials [options]
Where [options] are any of the following:
Name | Short name | Description |
---|---|---|
--account <account> | (Required) Account or order identifier associated with your credentials | |
--password <password> | (Required) Password associated with your credentials |
Example:
zendphpctl repo credentials --account ORDER_ID --password PASSWORD
Uninstall the ZendPHP package repository (repo uninstall)
The 'repo uninstall' command lets you uninstall the ZendPHP package repository from your system.
zendphpctl repo-uninstall
; please update to use the new command name.For example:
zendphpctl repo uninstall [options]
Example:
zendphpctl repo uninstall
Work with PHP versions
Install a new PHP version (php install)
The 'php install' command lets you install another PHP version in your environment. Specify a PHP minor version when running this command.
zendphpctl php-install
; please update to use the new command name.For example:
zendphpctl php install {PHP_VERSION}
Where {PHP_VERSION} is an argument used to set the PHP minor version to configure.
Default: If not provided, it uses the default PHP version; for more information, see the command php set-default
.
Example:
zendphpctl php install 7.4
List installed PHP versions (php list installed)
The 'php list installed' command lets you list all of the installed PHP versions in your environment.
zendphpctl php-list installed
; please update your scripts to use the new command name.For example:
zendphpctl php list installed
Change which PHP version is default (php set-default)
The 'php set-default' command lets you set an installed PHP version as the default to use when calling PHP on the command line. Specify a PHP minor version when running this command.
zendphpctl php-set-default
; please update to use the new command name.For example:
zendphpctl php set-default {PHP_VERSION}
Where {PHP_VERSION} is an argument used to specify the PHP minor version to set as the default.
Example:
zendphpctl php set-default 8.1
Edit configuration for a PHP version (php config)
The 'php config' command lets you configure a PHP version for use with PHP-FPM, rather than the default of CLI. If a PHP minor version is not specified, the command will use whatever you have set as your default version.
zendphpctl php-config
; please update to use the new command name.$EDITOR
environment variable. The command will raise an error if it cannot identify an editor.For example:
zendphpctl php config {PHP_VERSION} [options]
Where {PHP_VERSION} is an argument used to set the PHP minor version to configure (uses default if not provided, see 'php set-default') and [options] are any of the following:
Name | Short name | Description |
---|---|---|
--fpm | Configure PHP for use with PHP-FPM (versus CLI) |
Example 1:
zendphpctl php config 8.1
Example 2:
zendphpctl php config 7.3 --fpm
Uninstall an installed PHP version (php uninstall)
The 'php uninstall' command lets you uninstall a previously installed PHP version. Specify a PHP minor version when running this command.
zendphpctl php-uninstall
; please update to use the new command name.For example:
zendphpctl php uninstall {PHP_VERSION}
Where {PHP_VERSION} is an argument used to set the PHP minor version to uninstall.
Example:
zendphpctl php uninstall 8.1
Execute a script via php (exec)
The 'exec' command lets you execute the given PHP script(s) using a selected PHP binary. If a PHP minor version is not specified, the command will use whatever you have set as your default version. You can also specify any arguments or flags while running the command.
For example:
zendphpctl exec [options] <arguments>
Where [options] are any of the following:
Name | Short name | Description |
---|---|---|
--php <version> | Specifies a PHP minor version to use; uses default PHP version (see 'php set-default') if not specified. |
You can also specify <arguments> to execute using the selected PHP version.
Example 1:
zendphpctl exec script.php
Example 2:
zendphpctl exec --php 8.1 test.php
Example 3:
zendphpctl exec --php 7.4 command.php argument and --flags --to-use
Work with PHP-FPM
fpm is-installed
The 'fpm is-installed' command lets you determine if FPM is installed for the specified PHP version. If a PHP minor version is not specified, the command will use whatever you have set as your default version.
zendphpctl fpm is-installed
; please update to use the new command name.For example:
zendphpctl fpm is-installed [options] {PHP_VERSION}
Where {PHP_VERSION} is an argument used to set the PHP minor version you are checking for FPM support; uses default if not provided (see 'php set-default').
Example 1:
zendphpctl fpm is-installed
Example 2:
zendphpctl fpm is-installed 8.1
fpm install
The 'fpm install' command lets you install FPM for an installed PHP version. If a PHP minor version is not specified, the command will use whatever you have set as your default version.
zendphpctl fpm-install
; please update to use the new command name.For example:
zendphpctl fpm install {PHP_VERSION}
Where {PHP_VERSION} is an argument used to set the PHP minor version to install FPM support for; uses default if not provided (see 'php set-default').
Example 1:
zendphpctl fpm install
Example 2:
zendphpctl fpm install 8.1
Configure FPM support (fpm config)
The 'fpm config' command lets you configure your instance of PHP-FPM. If a PHP minor version is not specified, the command will use whatever you have set as your default version.
zendphpctl fpm-config
; please update to use the new command name.$EDITOR
environment variable. The command will raise an error if it cannot identify an editor.For example:
zendphpctl fpm config {PHP_VERSION}
Where {PHP_VERSION} is an argument used to set the PHP minor version to configure FPM support for; uses default if not provided (see 'php set-default').
Example 1:
zendphpctl fpm config
Example 2:
zendphpctl fpm config 8.1
fpm uninstall
The 'fpm uninstall' command lets you uninstall FPM for an installed PHP version. If a PHP minor version is not specified, the command will use whatever you have set as your default version.
zendphpctl fpm-uninstall
; please update to use the new command name.For example:
zendphpctl fpm uninstall {PHP_VERSION}
Where {PHP_VERSION} is an argument used to set the PHP minor version to uninstall FPM support for; uses default if not provided (see 'php set-default').
Example 1:
zendphpctl fpm uninstall
Example 2:
zendphpctl fpm uninstall 8.1
Work with PHP extensions
List PHP extensions available via package manager (ext list-packages)
The 'ext list-packages' command lets you list extensions that you can install via the package manager for a specified PHP version. If a PHP minor version is not specified, the command will use whatever you have set as your default version.
zendphpctl ext-list-packages
; please update to use the new command name.For example:
zendphpctl ext list-packages {PHP_VERSION}
Where {PHP_VERSION} is an argument used to set the PHP minor version for which to list available extension(s); uses default if not provided (see 'php set-default').
Example 1:
zendphpctl ext list-packages
Example 2:
zendphpctl ext list-packages 7.4
List currently enabled PHP extensions (ext list-enabled)
The 'ext list-enabled' command lets you list extensions currently enabled for a specified PHP version. This includes both packaged extensions and PECL extensions that you have compiled, installed, and enabled for your machine. If a PHP minor version is not specified, the command will use whatever you have set as your default version.
zendphpctl ext-list-enabled
; please update to use the new command name.For example:
zendphpctl ext list-enabled [options] {PHP_VERSION}
Where [options] are any of the following:
Name | Short name | Description |
---|---|---|
--fpm | List extensions enabled only for PHP-FPM (versus CLI) - DEB only |
{PHP_VERSION} is an argument used to set the PHP minor version to list enabled extensions for; uses default if not provided (see 'php set-default').
Example 1:
zendphpctl ext list-enabled
Example 2:
zendphpctl ext list-enabled 7.4
Example 3:
zendphpctl ext list-enabled 7.4 --fpm
Install an extension (ext install)
The 'ext install' command lets you install one or more PHP extensions. The default behavior is to install existing ZendPHP extension packages if they exist, and otherwise pull the extension from PECL, compile, and install it. If a PHP minor version is not specified, the command will use whatever you have set as your default version.
zendphpctl ext-install
; please update your scripts to use the new command name.Notes
- Some extensions require additional dependencies in order to compile. It is your responsibility to identify and install these dependencies.
- We do not specify any non-default configure flags; if you have specific flags you want to enable, you need to manually compile the extension yourself.
-
This command can both install package-delivered extensions, and compile and install PECL extensions. If priority (used when loading an extension) or an extension version are provided, it always compiles and installs from source.
For example:
zendphpctl ext install [options] <arguments>
Where [options] are any of the following:
Name | Short name | Description |
---|---|---|
--php <version> | Specifies a PHP minor version to use; uses default PHP version (see 'php set-default') if not specified. | |
--sapi <SAPI> | Install an extension only for a specified SAPI (for example, 'cli' or 'fpm') - DEB only. |
You can also specify argument(s) to install one or more extensions. Extensions should be specified with the following format:
{priority-}extension{-version}
{priority-} is used to indicate loading priority; the default, if not specified, is 20, but some extensions (for example, Swoole or OpenSwoole) need to be loaded after other extensions (such as JSON) and should specify a higher priority number (higher loads later). You can use {-version} to indicate a specific extension version to install. If either {priority-} or {-version} are specified, the command will always pull and compile from PECL.
Example 1:
zendphpctl ext install imap
Example 2:
zendphpctl ext install --php 8.1 ldap mysqli redis
Example 3:
zendphpctl ext install --php 7.4 60-swoole-4.8.1
Enable a PHP extension (ext enable)
The 'ext enable' command lets you enable one or more PHP extensions. If a PHP minor version is not specified, the command will use whatever you have set as your default version.
zendphpctl ext-enable
; please update to use the new command name.For example:
zendphpctl ext enable [options] <arguments>
Where [options] are any of the following:
Name | Short name | Description |
---|---|---|
--php <version> | Specifies a PHP minor version to use; uses default PHP version (see 'php set-default') if not specified. | |
--sapi <SAPI> | Install an extension only for a specified SAPI (for example, 'cli' or 'fpm') - DEB only. |
You can also specify argument(s) to enable one or more extensions (see the examples below).
Example 1:
zendphpctl ext enable imap
Example 2:
zendphpctl ext enable --php 8.1 ldap mysqli redis
Example 3:
zendphpctl ext enable --php 7.4 --fpm soap
Disable a PHP extension (ext disable)
The 'ext disable' command lets you disable one or more PHP extensions. If a PHP minor version is not specified, the command will use whatever you have set as your default version.
zendphpctl ext-disable
; please update to use the new command name.For example:
zendphpctl ext disable [options] <arguments>
Where [options] are any of the following:
Name | Short name | Description |
---|---|---|
--php <version> | Specifies a PHP minor version to use; uses default PHP version (see 'php set-default') if not specified. | |
--sapi <SAPI> | Install an extension only for a specified SAPI (for example, 'cli' or 'fpm') - DEB only. |
You can also specify argument(s) to enable one or more extensions (see the examples below).
Example 1:
zendphpctl ext disable imap
Example 2:
zendphpctl ext disable --php 8.1 ldap mysqli redis
Example 3:
zendphpctl ext disable --php 7.4 --fpm soap
Update the zendphpctl script (self-update)
The 'self-update' command lets you update the zendphpctl script to the latest version.
For example:
zendphpctl self-update
Example:
zendphpctl self-update
Work with Apache mod_php support
Install mod_php support (apache mod_php install)
The 'apache mod_php install' command installs the Apache mod_php SAPI for the given PHP version. If no PHP version is provided, it uses the default (assuming at least one version has been installed).
For example:
zendphpctl apache mod_php install {PHP_VERSION}
Where {PHP_VERSION} is an argument used to set the PHP minor version to configure.
Default: If not provided, it uses the default PHP version; for more information, see the command php set-default
.
Example 1:
zendphpctl apache mod_php install
Example 2:
zendphpctl apache mod_php install 7.4
Check if mod_php support is installed (apache mod_php is-installed)
The 'apache mod_php is-installed' command determines if Apache mod_php SAPI support is installed for the given PHP version. If no PHP version is provided, it uses the default (assuming at least one version has been installed).
For example:
zendphpctl apache mod_php is-installed {PHP_VERSION}
Where {PHP_VERSION} is an argument used to set the PHP minor version to configure.
Default: If not provided, it uses the default PHP version; for more information, see the command php set-default
.
Example 1:
zendphpctl apache mod_php is-installed
Example 2:
zendphpctl apache mod_php is-installed 7.4
Uninstall mod_php support (apache mod_php uninstall)
The 'apache mod_php uninstall' command uninstalls the Apache mod_php SAPI for the given PHP version, if it was previously installed. If no PHP version is provided, it uses the default (assuming at least one version has been installed).
For example:
zendphpctl apache mod_php uninstall {PHP_VERSION}
Where {PHP_VERSION} is an argument used to set the PHP minor version to configure.
Default: If not provided, it uses the default PHP version; for more information, see the command php set-default
.
Example 1:
zendphpctl apache mod_php uninstall
Example 2:
zendphpctl apache mod_php uninstall 7.4
Upgrad from previous versions
From zendphpctl version 0.2.20 on, command names use a hierarchical, nested subcommand structure. All previous command names continue to work, but we recommend updating any automation scripts to use the new commands. The following is a table detailing the original command names, and the new commands to use.
Original command name (<0.2.20) | New command name (>=0.2.20) |
---|---|
zendphpctl ext-disable | zendphpctl ext disable |
zendphpctl ext-enable | zendphpctl ext enable |
zendphpctl ext-install | zendphpctl ext install |
zendphpctl ext-list-enabled | zendphpctl ext list-enabled |
zendphpctl ext-list-disabled | zendphpctl ext list-disabled |
zendphpctl ext-list-packages | zendphpctl ext list-packages |
zendphpctl fpm-config | zendphpctl fpm config |
zendphpctl fpm-install | zendphpctl fpm install |
zendphpctl fpm-is-installed | zendphpctl fpm is-installed |
zendphpctl fpm-uninstall | zendphpctl fpm uninstall |
zendphpctl php-config | zendphpctl php config |
zendphpctl php-exec | zendphpctl php exec |
zendphpctl php-install | zendphpctl php install |
zendphpctl php-list-installed | zendphpctl php list-installed |
zendphpctl php-set-default | zendphpctl php set-default |
zendphpctl php-uninstall | zendphpctl php uninstall |
zendphpctl repo-credentials | zendphpctl repo credentials |
zendphpctl repo-install | zendphpctl repo install |
zendphpctl repo-uninstall | zendphpctl repo uninstall |
zendphpctl zendhq-token | zendphpctl zendhq token |
zendphpctl zray-plugin-disable | zendphpctl zray plugin disable |
zendphpctl zray-plugin-enable | zendphpctl zray plugin enable |
zendphpctl zray-plugins-install | zendphpctl zray plugin install |
zendphpctl zray-plugins-list | zendphpctl zray plugin list |