Installing ZendPHP on OracleLinux

This topic describes the procedures for installing ZendPHP on an OracleLinux based operating system. ZendPHP supports OracleLinux 7, 8, and 9.

If you are installing ZendPHP on OracleLinux versions 7, please install the software collections package first. This is standard on OracleLinux and allows you to install multiple versions of PHP.

Note OracleLinux 8 switches from using the yum tool to using dnf. The tools have identical usage. When installing on OracleLinux 8 or above, wherever you see yum in this guide, substitute dnf.

Set up repository on OracleLinux

Before installing ZendPHP for the first time, set up your repository:

  1. Add the ZendPHP yum repositories:

    $ sudo echo -e "[zendphp] name=ZendPHP (x86_64) baseurl=https://<username>:<password>{OS_VERSION}/x86_64/ enabled=1 gpgcheck=1 gpgkey= [zendphp_noarch] name=Zendphp (noarch) baseurl=https://<username>:<password>{OS_VERSION}/noarch/ enabled=1 gpgcheck=1 gpgkey= " > /etc/yum.repos.d/zendphp.repo

    In the code snippet, replace the following values:

  2. Update your package sources:

    sudo yum update

Install ZendPHP on OracleLinux

After setting up your repository and updating the packages, you can now install ZendPHP.

  1. Install the PHP packages:

    sudo yum install php{PHP_VERSION}zend

    This installs the common modules and the CLI binary for the specified version. If you would like to explore the additional packages that are available, use sudo yum search php{PHP_VERSION}zend to search our package library.

    Some packages have requirements that are found in the Extra Packages for Enterprise Linux (EPEL) repository. If a package indicates that a requirement cannot be found, install the EPEL repository:

    sudo yum install -y epel-release # Force YUM to refresh the repository list and install keys: sudo yum repolist

    Note To make the version you are installing the system default, install the package php{VERSION}zend-syspaths. For example, to install the 7.4 CLI and make it the system default use:
       sudo yum install -y php74zend php74zend-syspaths
  2. Switching PHP versions. OracleLinux packages use software collections to allow installing multiple PHP versions on the same machine. You can list them and switch between them using the scl command

    scl list-collections scl load php{PHP_VERSION}zend

    Note If you did not install the syspaths package for your PHP version, you MUST use scl load to enable it and make it available on your path.
  3. [Optional] On Apache2, install httpd and the PHP package (representing mod_php) for your ZendPHP version:

    sudo yum install httpd php{PHP_VERSION}zend-php

    This enables mod_php under httpd by default. If you have other versions installed, you need to rename their configuration files so that you can use the one for your desired version. Look for files named php*-zend-php.conf in the directory /etc/httpd/conf.d/. Rename any files for versions you are not using to append a .tmp or .bak suffix. Once you have, restart httpd:

    sudo systemctl restart httpd

  4. [Optional] To install FastCGI on Apache2, you need to install httpd, and the php-fpm package for your PHP version:

    sudo yum install httpd php{VERSION}zend-php-fpm

    From here, you can start your php-fpm pool and Apache:

    sudo systemctl start httpd sudo systemctl start php{PHP_VERSION}zend-php-fpm

    Configuration for the pool is in the /etc/opt/zend/php{VERSION}zend/ directory.

  5. [Optional] To install FastCGI on nginx, you need to install the php-fpm package for your PHP version and nginx:

    sudo yum install nginx php{PHP_VERSION}zend-php-fpm

    From here, you need to create a virtual host configuration for nginx that proxies PHP requests to FastCGI as handled by your PHP version. For example on PHP 7.4 you need to edit the /etc/nginx/nginx.conf file to make the default host read:

    server { listen 80; root /var/www/html; server_name _; index index.html index.html index.php; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/opt/zend/php74zend/run/php-fpm/ } }

    Now start the php-fpm pool and restart nginx:

    sudo systemctl restart nginx sudo systemctl start php{PHP_VERSION}zend-php-fpm

Installing and using PECL on OracleLinux

The PECL binary, used to compile and install extensions shipped via, is available via the php{VERSION}zend-php-pear package and requires the php{VERSION}zend-php-devel package. You also need build tools, generally provided via gcc, gcc-c++, and make packages. You can install everything at once as follows:

sudo yum install -y gcc gcc-c++ \ make php{PHP_VERSION}zend-php-devel \ php{PHP_VERSION}zend-php-pear

This installs the PECL binary to /opt/zend/php{VERSION}zend/root/bin/pecl.

Installing an extension

Installing an extension via the PECL binary follows the generic instructions for all platforms:

sudo scl enable php{PHP_VERSION}zend 'pecl install {extension_name}'

Enabling an extension

Once compiled, you need to enable the extension. Generally, PECL provides information like the following on successful completion:

install ok: channel:// configuration option "php_ini" is not set to php.ini location You should add "" to php.ini

The important piece is the section contained in quotes in the last line. Copy that information and create a file named 20-extensionname.ini in /etc/opt/zend/php{PHP_VERSION}zend/php.d/ as follows:

sudo echo "; Enable extension-name extension module" > /etc/opt/zend/php{VERSION}zend/php.d/20-extension-name.ini

Once done, run php -m to verify that your extension is enabled.