Adding PHP versions on CentOS7 and ISPConfig
Currently I’m using ISPConfig to manage serveral websites and the accompanying things like dns, mail, databases etc..
This setup runs on CentOS7 since that’s my preffered OS. By default CentOS7 comes with php 5.4 which has gone EOL this September. A lot of the newer php based applications like Drupal8 want at least php 5.5 so it was time to update.
Since the default php version is supported and receives backports until the EOL of the CentOS release I decided to keep the default 5.4 version and to add the newer versions as an option. ISPConfig also provides a way to use multiple PHP version.
Software Collections.
The RHEL “ecosystem” has something called Software Collections for some time now and the goal is to have more up to date software available without having to update the default packages.
Install the Software Collections
Install the software collection utils.
yum install scl-utils
Install the php version you want to add by adding the scl repo. The link can be found on the software collections website.
rpm -ivh https://www.softwarecollections.org/en/scls/rhscl/php55/epel-7-x86_64/download/rhscl-php55-epel-7-x86_64.noarch.rpm
Install php packages
Next, install the php packages you need. In my setup I make use of php-fpm to run php applications.
yum install php55-php php55-php-mysqlnd php55-php-fpm php55-php-mbstring
php55-php-opcache
You can now test the php version by enabeling the software collection. Software Collections make use of a special file system hierarchy to avoid possible conflicts between a single Software Collection and the base system installation. These are stored in /opt/rn/
[root@scl-test ~]# scl enable php55 bash
Check the version.
[root@scl-test ~]# php -v
PHP 5.5.21 (cli) (built: Jun 26 2015 06:07:04)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
[root@scl-test ~]#
Configure php-fmp and ISPConfig
To avaiod conflicts with my current running php-fpm service, we need to change the port of the php-fpm service from the collection.
sed -e 's/9000/9500/' -i /opt/rh/php54/root/etc/php-fpm.d/www.conf
If you have SELinux enabled you also need to execute
semanage port -a -t http_port_t -p tcp 9500
Now you
systemctl start php55-php-fpm