Quantcast
Channel: Severalnines - clustercontrol
Viewing all articles
Browse latest Browse all 385

ClusterControl Tips and Tricks: Running ClusterControl on PHP 7

$
0
0

ClusterControl consists of multiple components and one of them is the user interface, a web application running on PHP platform. Some customers had concerns since PHP 5.x was deprecated early this year. This blog post shows you how you would run ClusterControl on PHP 7.x.

What's up with PHP 5?

PHP 5 has reached the end of life on January 1st, 2019. Each release branch of PHP is fully supported for two years from its initial stable release. During this period, bugs and security issues that have been reported are fixed and are released in regular point releases. End of life (EOL) simply means the release is no longer supported. Users of this release should upgrade as soon as possible, as they may be exposed to unpatched security vulnerabilities.

While ClusterControl already supports PHP 7 since version 1.6.1 (release date - May 25th, 2018), some OS distribution still offers PHP 5 in its default repository. The following list shows the supported OS alongside its PHP packages in the repository:

  • Ubuntu 18.04 (Bionic) - PHP 7.2
  • Ubuntu 16.04 (Xenial) - PHP 7.0
  • Ubuntu 14.04 (Trusty) - PHP 5.5
  • Debian 9 (Stretch) - PHP 7.0
  • Debian 8 (Jessie) - PHP 5.6
  • Debian 7 (Wheezy) - PHP 5.4
  • CentOS/RHEL 6 - PHP 5.3
  • CentOS/RHEL 7 - PHP 5.4

Up until today, the active PHP versions are 7.2 and 7.3, as shown in the following Gantt chart (taken from http://php.net/supported-versions.php):

Note that even PHP 7.1 has entered passive support with security fixes only until Dec 1st, 2019. Considering all the options we have here, the following operating systems offers an outdated PHP version:

  • Debian 9 (Stretch)
  • Debian 8 (Jessie)
  • Debian 7 (Wheezy)
  • Ubuntu 16.04 (Xenial)
  • Ubuntu 14.04 (Trusty)
  • CentOS/RHEL 6
  • CentOS/RHEL 7

It is probably the right time to upgrade the PHP at least up to version 7.1 to avoid security concerns and get peace of mind when running web applications.

Installing ClusterControl with PHP 7

CentOS/RHEL

For new installation, the best way for now is to use third-party repository that offers PHP 7 packages. For RHEL/CentOS system, you can enable Remi repository which uses the same generic name for PHP packages. First, enable the Remi repository:

For CentOS/RHEL 7:

$ yum install -y epel-release
$ wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
$ rpm -Uvh remi-release-7.rpm
$ sed -i s/enabled=0/enabled=1/g /etc/yum.repos.d/remi-php73.repo

For CentOS/RHEL 6:

$ yum install -y epel-release
$ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
$ rpm -Uvh remi-release-6.rpm
$ sed -i s/enabled=0/enabled=1/g /etc/yum.repos.d/remi-php73.repo

Then, proceed with the ClusterControl installation as usual:

$ wget severalnines.com/downloads/cmon/install-cc
$ chmod 755 install-cc
$ ./install-cc

ClusterControl will be installed on top of PHP 7.3. There are a number of third-party repositories that offer PHP 7 installation like Webstatic, RPMFusion and so on. However, using the Remi repository is the best option we got considering it requires zero modification to the ClusterControl installer script.

Ubuntu/Debian

The following is applicable for Ubuntu and Debian OS platform. On ClusterControl run, configure "ondrej/php" PPA repository. The following example is what you should have executed on an Ubuntu 16.04 (Xenial) server:

$ apt-get install -y software-properties-common language-pack-en-base
$ LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php

Download the installer script:

$ wget severalnines.com/downloads/cmon/install-cc

For the following operating systems, we have to make a small modification to instruct the script to install the latest PHP 7:

  • Debian 8 (Jessie)
  • Debian 7 (Wheezy)
  • Ubuntu 14.04 (Trusty)

The installer script is configured to use php5-* packages for the above OSes. You can see the line that corresponds to this check starting at line 312, as shown in the following code snippet:

    case "${os_codename}" in
        'bionic' | 'xenial' | 'stretch')
            # prefixes packages simply with 'php'
            install_packages="${install_packages} php-xml"
            install_packages="`echo $install_packages | sed 's/php5/php/g'`"
            ;;
    esac

Thus, if the operating system is not listed there (right below the "case" line), we have to add the OS code name into the list. In this example, we are adding Ubuntu 14.04 (Trusty) into the list so the installer will use the php-* packages instead of php5-* packages (as shown in the "sed" command). Add the OS codename into line 313, similar to the example below:

'bionic' | 'xenial' | 'stretch' | 'trusty')

You can use "lsb_release -a" command to get the OS codename. Finally, proceed with the ClusterControl installation as usual:

$ chmod 755 install-cc
$ ./install-cc

You will end up with PHP 7.2 installed, which is good enough to run the ClusterControl web application.

Upgrading to PHP 7

For those who already installed ClusterControl with PHP 5.x, it's possible to upgrade the PHP version to the latest one. Basically, the same principle applies to what we described in the previous section.

CentOS/RHEL

Install and enable the third-party package repository. In this case, we are using Remi repository:

For CentOS/RHEL 7:

$ yum install -y epel-release
$ wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
$ rpm -Uvh remi-release-7.rpm
$ sed -i s/enabled=0/enabled=1/g /etc/yum.repos.d/remi-php73.repo

For CentOS/RHEL 6:

$ yum install -y epel-release
$ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
$ rpm -Uvh remi-release-6.rpm
$ sed -i s/enabled=0/enabled=1/g /etc/yum.repos.d/remi-php73.repo

Then, perform the upgrade accordingly:

$ yum upgrade -y php-*

Once done, restart Apache web server to load the new PHP version:

$ systemctl restart httpd # CentOS/RHEL 7
$ service httpd restart # CentOS/RHEL 6

Re-login into the ClusterControl UI and you should be good.

Ubuntu/Debian

The following is applicable for Ubuntu and Debian OS platform. First of all, verify if the ClusterControl server is installed with php5-* or php-* package name:

$ dpkg --list | grep -i php5-
ii  php5-cli                        5.5.9+dfsg-1ubuntu4.26                     amd64        command-line interpreter for the php5 scripting language
ii  php5-common                     5.5.9+dfsg-1ubuntu4.26                     amd64        Common files for packages built from the php5 source
ii  php5-curl                       5.5.9+dfsg-1ubuntu4.26                     amd64        CURL module for php5
ii  php5-gd                         5.5.9+dfsg-1ubuntu4.26                     amd64        GD module for php5
ii  php5-json                       1.3.2-2build1                              amd64        JSON module for php5
ii  php5-ldap                       5.5.9+dfsg-1ubuntu4.26                     amd64        LDAP module for php5
ii  php5-mysql                      5.5.9+dfsg-1ubuntu4.26                     amd64        MySQL module for php5
ii  php5-readline                   5.5.9+dfsg-1ubuntu4.26                     amd64        Readline module for php5

If you got something like the above, remove all PHP 5 related packages first:

$ apt-get remove php5-* libapache2-mod-php5

Otherwise, you may skip the above step. On ClusterControl run, configure "ondrej/php" PPA repository. The following example is what you should have executed on an Ubuntu server:

$ apt-get install -y software-properties-common language-pack-en-base
$ LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php

Then, update the repolist followed by upgrading the PHP packages:

$ apt-get update
$ apt-get install libapache2-mod-php php-cli php-common php-curl php-gd php-json php-ldap php-mysql php-readline php-xml

Restart the Apache web server to load the new changes:

$ systemctl restart apache2 # systemd
$ service apache2 restart # sysvinit or upstart

Re-login ClusterControl UI. It should be running on PHP 7.2 at this point. You may verify with phpinfo() page or using the "php --version" command.

Final Thoughts

It's highly recommended to keep up with the active supported version for all dependencies of your applications. This ensures that you run the overall infrastructure with minimal security risks, and better performance.


Viewing all articles
Browse latest Browse all 385

Trending Articles