Múltiplas versões do PHP + CentOS

De Wiki Hackstore

Requisitos

# yum install gcc libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel freetype-devel icu libicu-devel gcc-c++ postgresql-devel aspell-devel git libmcrypt-devel -y
# yum install firebird-devel unixODBC-devel --enablerepo=epel

Compile o phpfarm

# cd /opt/
# git clone https://github.com/cweiske/phpfarm.git phpfarm
# cd phpfarm/src/
# cd /opt/phpfarm/src/

PHP 5.2

# cd /opt/phpfarm/src ; vi custom-options-5.2.11.sh
#!/bin/bash

#gcov='--enable-gcov'
configoptions="
--disable-debug \
--with-config-file-path=/opt/phpfarm/inst/php-5.2.11/lib/ \
--with-libdir=lib64 \
--enable-short-tags \
--with-pear \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-pcntl \
--enable-soap \
--enable-sockets \
--enable-wddx \
--enable-zip \
--with-zlib \
--with-gettext \
--enable-pdo \
--enable-cgi \
--enable-mysql \
--with-mysql \
--with-mysqli \
--enable-json \
--with-curl \
--with-openssl \
--with-apxs2=/usr/sbin/apxs \
--with-interbase=/opt/firebird \
--with-pdo-firebird=/opt/firebird \
--with-pdo-pgsql \
--with-bz2 \
--with-mcrypt \
--with-pgsql \
$gcov"
#--with-mysql \
#--enable-mysql \
#--with-mysqli=mysqlnd \
#--with-mysql-dir=/usr/ \
#--with-mysql=mysql \
#--with-mysqli=/usr/bin/mysql_config \
#--with-pdo-mysql=mysql \
#--with-mysqli=mysql \
#--with-pdo-mysql \
#--with-pdo-odbc=unixODBC,/usr/local \


compile

# nohup ./compile.sh 5.2.11 > compile-5.2.11.log


PHP 5.6

# cd /opt/phpfarm/src ; vi custom-options-5.6.31.sh
#!/bin/bash

#gcov='--enable-gcov'
configoptions="
--disable-debug \
--with-config-file-path=/opt/phpfarm/inst/php-5.6.31/lib/ \
--enable-short-tags \
--with-pear \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-pcntl \
--enable-soap \
--enable-sockets \
--enable-wddx \
--enable-zip \
--with-zlib \
--with-gettext \
--enable-pdo \
--with-pdo-mysql \
--enable-cgi \
--enable-json \
--with-curl \
--with-openssl \
--enable-openssl \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-firebird=/opt/firebird \
--with-pdo-mysql=mysqlnd \
--with-interbase=/opt/firebird \
--with-pdo-pgsql \
--with-pdo-odbc=unixODBC,/usr \
--with-bz2 \
--with-mcrypt \
--with-pgsql \
$gcov"
#--with-mysql \
#--enable-mysql \

compile

# nohup ./compile.sh 5.6.31 > compile-5.6.31.log &

Após compilar, crie o arquivo /var/www/cgi-bin/php.fastcgi.5.6 com o seguinte conteúdo:

#!/bin/bash

PHPRC="/opt/phpfarm/src/php-5.6.31/php.ini-development"
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=1000
export PHPRC
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS

exec /opt/phpfarm/inst/bin/php-cgi-5.6.31

PHP 7.0

# cd /opt/phpfarm/src ; vi custom-options-7.0.22.sh
#!/bin/bash

#gcov='--enable-gcov'
configoptions="
--disable-debug \
--with-config-file-path=/opt/phpfarm/inst/php-7.0.22/lib/ \
--enable-short-tags \
--with-pear \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-pcntl \
--enable-soap \
--enable-sockets \
--enable-wddx \
--enable-zip \
--with-zlib \
--with-gettext \
--enable-pdo \
--with-pdo-mysql \
--with-pdo-firebird=/opt/firebird \
--enable-cgi \
--enable-json \
--with-curl \
--with-openssl \
--enable-openssl \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-interbase=/opt/firebird \
--with-pdo-pgsql \
--with-pdo-odbc=unixODBC,/usr \
--with-bz2 \
--with-mcrypt \
--with-pgsql \
$gcov"
#--with-mysql \
#--enable-mysql \


compile

# nohup ./compile.sh 7.0.22 > compile-7.0.22.log &


Após compilar, crie o arquivo /var/www/cgi-bin/php.fastcgi.7.0 com o seguinte conteúdo:

#!/bin/bash

PHPRC="/opt/phpfarm/src/php-7.0.22/php.ini-development"
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=1000
export PHPRC
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS

exec /opt/phpfarm/inst/bin/php-cgi-7.0.22


Configure o vhost no apache

PHP 5.6

<VirtualHost *:80>
DocumentRoot "/var/www/sitephp56/"
ServerName sitephp56
<Directory "/var/www/sitephp56/">
           Options +Indexes FollowSymLinks +ExecCGI
            AddHandler php5-fastcgi .php
            Action php5-fastcgi /cgi-bin/php.fastcgi.5.6
            AllowOverride All
            Order allow,deny
            Allow from All
</Directory>
</VirtualHost>

PHP 7.0

<VirtualHost *:80>
DocumentRoot "/var/www/sitephp70/"
ServerName sitephp70
<Directory "/var/www/sitephp70/">
           Options +Indexes FollowSymLinks +ExecCGI
            AddHandler php5-fastcgi .php
            Action php5-fastcgi /cgi-bin/php.fastcgi.7.0
            AllowOverride All
            Order allow,deny
            Allow from All
</Directory>
</VirtualHost>