Centos, Owncloud and PHP 5.6/7.1

Centos 7 comes with PHP 5.4, securitywise this is not a problem, fixes get backported by RedHat, but Owncloud X (and likewise Nextcloud) need at least PHP 5.6. And naturally other web apps may also gain from newer PHP versions.

There is a more or less official way to have newer PHP versions on Centos and RHEL, Software Collections. There is PHP 5.6 and PHP 7.0. A slightly less official way for a current version is the Remi repository with PHP 7.1.

The Software Collection-way of installation is parallel installation, this means the newer PHP ist installed side by side to the system’s version (look in /opt, /etc/opt and /var/opt paths) and is only used if called explicitly. This is very clean but not very practical. You easily find howtos on globally changing the system’s PHP Version to the new one, especially for the Apache httpd Server, the main consumer of PHP. Remi also a has “replacing” way of installation.

But what if other web apps like Kolab won’t work with anything else than PHP 5.4?

The reason is, Kolab uses libraries which get compiled against the distribution’s PHP version. PHP-FPM comes to the rescue. It allows to selectively use different PHP versions (even more than two if you want), so Kolab stays on 5.4 and Owncloud gets 7.1. The easiest way is to bring Owncloud 9 to PHP 7.1 and do then the upgrade to Owncloud X. Make backups before upgrading (at least of the database), there is no other way back to Owncloud 9 if anything fails.

So let’s get started, for the receipt is doesn’t matter which version of PHP you choose to install, only the repositories and names change accordingly. Use the Remi wizard to get the repos installed. For Owncloud X you do

yum install php71-php php71-php-common php71-php-mysqlnd php71-php-xml php71-php-fpm  php71-php-gd  php71-php-pdo php71-php-process php71-php-ldap php71-php-mbstring php71-php-cli php71-php-json php71-php-intl

Edit the file /etc/opt/remi/php71/php-fpm.d/www.conf and change at least the listen-directive to listen = 127.0.0.1:9071(to have a dedicated port 9071 for PHP 7.1). Edit the file /etc/httpd/conf.d/owncloud.conf and add to the first Directory-directive

 <FilesMatch \.php$>
	SetHandler "proxy:fcgi://127.0.0.1:9071"
 </FilesMatch>

Then start the FPM service and restart the web server:

systemctl enable php71-php-fpm
systemctl start php71-php-fpm
systemctl restart httpd

Don’t forget to restart the FPM service when you made changes to PHP 7.1.

UPDATE 2017-10-05: The new rh-php71 collection is also available in the centos-sclo-rh-testing repostiory for CentOS users.

Advertisements

One thought on “Centos, Owncloud and PHP 5.6/7.1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s