Skip to content

Instantly share code, notes, and snippets.

@ricardo85x
Created August 16, 2019 14:22
Show Gist options
  • Save ricardo85x/9ef2b433b33e386acee42b773c304f7e to your computer and use it in GitHub Desktop.
Save ricardo85x/9ef2b433b33e386acee42b773c304f7e to your computer and use it in GitHub Desktop.
How to configure Multi php on Centos 6 with default PHP5.3 and new PHP 7.2
Let's assume you alread have a old system running with php5.3
# 1 - Install Remi and Epel repository
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# Install php72
yum install php72-runtime php72-php-common php72 php72-php-fpm php72-php-mysqlnd php72-php-json php72-php-xml php72-php-mbstring php72-php-pdo php72-php-cli
# install mode_fastcgi
rpm -Uvh http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el6/en/x86_64/rpmforge/RPMS/mod_fastcgi-2.4.6-2.el6.rf.x86_64.rpm
# remove/comment every configuration on /etc/httpd/conf.d/php.ini
# Create the following files:
/var/www/cgi-bin/php5.fcgi
#!/bin/bash
PHPRC="/etc/php.ini"
PHP_CGI=/usr/bin/php-cgi
PHP_FCGI_CHILDREN=8
PHP_FCGI_MAX_REQUESTS=3000
export PHPRC
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec $PHP_CGI
/var/www/cgi-bin/php7.fcgi
#!/bin/bash
PHPRC="/etc/opt/remi/php72/php.ini"
PHP_CGI2=/opt/remi/php72/root/usr/bin/php-cgi
PHP_FCGI_CHILDREN=8
PHP_FCGI_MAX_REQUESTS=3000
export PHPRC
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec $PHP_CGI2
# make executable and set the owner:
chmod a+x /var/www/cgi-bin/*
chown apache:apache /var/www/cgi-bin/*
# let's keep the php5 on default por 80 and configure php7 on port 8070
# Remove any VirtualHost's configuration with port 80 or 8070, and add the following on /etc/httpd/conf/httpd.conf
Listen 80
Listen 8070
<VirtualHost *:80>
DocumentRoot /var/www/html
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory /var/www/html >
Options +Indexes FollowSymLinks +ExecCGI
AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php5.fcgi
AllowOverride All
Order allow,deny
Allow from All
</Directory>
</VirtualHost>
<VirtualHost *:8070>
DocumentRoot /var/www/html
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory /var/www/html>
Options +Indexes FollowSymLinks +ExecCGI
AddHandler php7-fastcgi .php
Action php7-fastcgi /cgi-bin/php7.fcgi
AllowOverride All
Order allow,deny
Allow from All
</Directory>
</VirtualHost>
# restart apache
service httpd restart
Now port 80 is php5 and port 8070 is php72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment