multiple versions of php with apache

NOTE: This is a Work In Progress post, published in note form for now, will revisit at later date.


steps to allow multiple versions of php with apache on centos 7

#remove current php and replace target repo

sudo yum remove php\*
sudo yum-config-manager --disable webtactic

sudo yum install centos-release-scl

#install php56
sudo yum -y install rh-php56 rh-php56-php-fpm rh-php56-php-bcmath rh-php56-php-cli rh-php56-php-common rh-php56-php-gd rh-php56-php-intl rh-php56-php-mbstring rh-php56-php-mcrypt rh-php56-php-mysql rh-php56-php-pdo rh-php56-php-pecl-redis rh-php56-php-soap rh-php56-php-xml rh-php56-php-xmlrpc

#set bash default
scl enable rh-php56 bash

#configure fpm
sudo sed -i 's/listen = 127.0.0.1:9000/listen = 127.0.0.1:9056/g' /etc/opt/rh/rh-php56/php-fpm.d/www.conf

sudo touch /var/log/php-fpm/php56_error.log
sudo sed -i 's/error_log = .*.log/error_log = \/var\/log\/php-fpm\/php56_error.log/g' /etc/opt/rh/rh-php56/php-fpm.conf

sudo systemctl start rh-php56-php-fpm
sudo systemctl enable rh-php56-php-fpm

#same again but for php7.0

sudo yum -y install rh-php70 rh-php70-php-fpm rh-php70-php-bcmath rh-php70-php-cli rh-php70-php-common rh-php70-php-gd rh-php70-php-intl rh-php70-php-mbstring rh-php70-php-mcrypt rh-php70-php-mysqlnd rh-php70-php-pdo rh-php70-php-pecl-redis rh-php70-php-soap rh-php70-php-xml rh-php70-php-xmlrpc

#only if you want php cli to be v7
scl enable rh-php70 bash

sudo sed -i 's/listen = 127.0.0.1:9000/listen = 127.0.0.1:9070/g' /etc/opt/rh/rh-php70/php-fpm.d/www.conf

sudo touch /var/log/php-fpm/php70_error.log
sudo sed -i 's/error_log = .*.log/error_log = \/var\/log\/php-fpm\/php70_error.log/g' /etc/opt/rh/rh-php70/php-fpm.conf

sudo systemctl start rh-php70-php-fpm
sudo systemctl enable rh-php70-php-fpm

# set apache default php version (eg to v5.6)
sudo nano /etc/httpd/conf.d/virtualhost.conf


SetHandler "proxy:fcgi://127.0.0.1:9056"

#set per project (eg to v7.0)


SetHandler "proxy:fcgi://127.0.0.1:9070"


Tags: , , ,

Enough of me, let me know your thoughts below...