If you have an OVH Server with CentOS Release 3, you could want to use in some website a new PHP version than PHP 5.3.3 which is included on this Linux distribution. Here you can see how to install PHP 5.6 working together with PHP 5.3.3.
First of all, you must add the yum repository. We recommend SCLs (Software Collections) because allow you to run the default version while also allowing a newer version of php to be installed alongside the default php for use creating and running software with newer requirements. Furthermore, the source code is rebuilt by the CentOS Project, so you can be sure that the packages won’t have their own mailing lists, IRC channels, issue trackers, etc.
We could see how to install on the below references, but we will resume it on this post:
PHP 5.6 Installation
Install SCLs and Remi repositories
1 2 |
$ sudo yum install centos-release-scl $ sudo yum install https://www.softwarecollections.org/en/scls/remi/php56more/epel-6-x86_64/download/remi-php56more-epel-6-x86_64.noarch.rpm |
Install the collection packages for PHP 5.6
1 |
$ sudo yum install rh-php56 rh-php56-php-fpm |
Remi collections packages use “more” prefix to avoid confusion with Red Hat packages. You can see which packages are available with this command
1 |
$ sudo yum list *php56* |
At this stage, you have the default PHP version working and PHP 5.6 version installed under ‘/opt/rh/rh-php56/’ directory and the configuration files under ‘/etc/opt/rh/rh-php56’ directory.
Site configuration
Since CentOS 6.7 OVH Release 3 makes use of suphp and fastcgi in the default configuration, we just have to set a couple of things to make our website run with the new PHP version.
In ‘/etc/suphp.conf’ file we add the handler for our php 5.6 php-cgi binary.
1 2 3 4 |
[handlers] ;Handler for php-scripts x-httpd-php="php:/usr/bin/php-cgi" x-httpd-php56="php:/opt/rh/rh-php56/root/usr/bin/php-cgi" |
Now we configure this handler in our apache configuration of the domain which work with PHP 5.6 version. In the file ‘/etc/httpd/vhost/YOUR_DOMAIN_FILE.conf’ we change current PHP handler to the new created in ‘/etc/suphp.conf’ file.
1 2 3 4 5 6 7 |
# Previous suPHP_AddHandler x-httpd-php AddHandler x-httpd-php .php # New suPHP_AddHandler x-httpd-php56 AddHandler x-httpd-php56 .php |
Note: If you are using HTTP and HTTPS, you should set up this handler in both of configuration files.
Restart apache server
We restart the apache and your website will run the new PHP 5.6
1 |
$ /etc/init.d/https restart |
We hope that this article was helpful for you, please let us know if do you have some question.