Use PHP 5.4 on OVH release 3 (centos 6 x86_64)

Use PHP 5.4 on OVH release 3 (centos 6 x86_64)

Posted By: pmietlicki

Published to Linux on Jun 03, 2015

Add remi repository with :

wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
/bin/rpm -Uvh remi-release-6*.rpm

Then install php54 with :

/usr/bin/yum --enablerepo=remi install php54-php-common php54-php-mcrypt php php54-php-fpm php54-php-mbstring

Create a new file called enable inside /opt/remi/php54 :

cd /opt/remi/php54
vi enable

With :

export PATH=/opt/remi/php54/root/usr/bin:/opt/remi/php54/root/usr/sbin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/opt/remi/php54/root/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export MANPATH=/opt/remi/php54/root/usr/share/man:${MANPATH}

Create the bash file for the wrapper :

cd /home/mydomain/cgi-bin 
vi php54-wrapper

With :

#!/bin/bash 
source 
/opt/remi/php54/enable 
exec php-cgi

Configure the virtual host :

cd /etc/httpd/vhosts 
vi mydomain.com.conf

Add these instructions inside the main part and if you have SSL, duplicate it inside the 443 part :

AddHandler php-cgi .php 
Action php-cgi /cgi-bin/php54-wrapper 

Options +ExecCGI

If you want to enable apache worker (may have better performance with php-fpm previously installed) :

Inside /etc/sysconfig/httpd, uncomment this line :

HTTPD=/usr/sbin/httpd.worker

Then restart apache !

If you need to change php configuration for this virtual host, don't forget you'll have to edit /opt/remi/php54/root/etc/php.ini

Inspired by : http://blog.diagram.fr/astuce-linux/utiliser-php-5...

Tags: Centos, FPM, OVH, php

Archive