Две версии php на одном сервере

Нуж­ную вер­сию мож­но най­ти вот тут:

Thank you for reading this post, don't forget to subscribe!

http://museum.php.net/php7/

Ста­вим зави­си­мо­сти что бы php собрал­ся как надо и без ошибок:
yum install -y wget gcc libxml2-devel openssl-devel libcurl-devel libpng-devel libmcrypt-devel libmhash-devel mysql-devel libtidy-devel libxslt-devel libtool-ltdl-devel mhash mhash-devel glibc-headers  libjpeg-devel*
yum install  -y httpd-devel libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel libXpm-devel freetype-devel t1lib-devel gmp-devel libicu-devel libmcrypt libmcrypt-devel aspell-devel readline-devel libtidy libtidy-devel libxslt-devel libwebp-devel gcc-c++ 
yum install \
libxml2-devel \
httpd-devel \
libXpm-devel \
gmp-devel \
libicu-devel \
t1lib-devel \
aspell-devel \
openssl-devel \
bzip2-devel \
libcurl-devel \
libjpeg-devel \
libvpx-devel \
libpng-devel \
freetype-devel \
readline-devel \
libtidy-devel \
libxslt-devel \
httpd-devel \
libxml2 \
libxml2-devel \
openssl \
openssl-devel \
bzip2 \
bzip2-devel \
curl \
curl-devel \
libjpeg \
libjpeg-devel \
libpng \
libpng-devel \
libXpm-devel \
freetype-devel \
t1lib-devel \
gmp-devel \
libicu-devel \
libmcrypt \
libmcrypt-devel \
aspell-devel \
libtidy \
libtidy-devel \
libxslt-devel \
libwebp-devel \
gcc-c++ \
wget \
gcc \
libxml2-devel \
openssl-devel \
libcurl-devel \
libpng-devel \
libmcrypt-devel \
libmhash-devel \
mysql-devel \
libtidy-devel \
libtool-ltdl-devel \
mhash mhash-devel \
glibc-headers \
libjpeg-devel*

если  уста­нов­лен mysql вер­сии 5.5 то тогда уста­нов­ку про­из­во­дим без mysql-devel, и ста­вим его отдель­но из репо­зи­то­рия remi

отме­тим, что mysql будет обнов­лён до вер­сии 5.5.60

После это­го начи­на­ем соби­рать, у меня вот такие параметры:

./configure --prefix=/opt/php5217 --enable-force-cgi-redirect --disable-debug --enable-libxml --with-libxml-dir=/usr/local --enable-reflection --enable-spl --enable-zend-multibyte --with-regex=system --with-tidy --enable-zip --enable-bcmath --enable-calendar --with-curl=shared --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-gettext=shared --enable-mbstring --with-mcrypt=/usr/include --with-mhash=shared --with-mysql --with-libdir=lib --with-openssl --with-pdo-mysql --enable-sockets --with-xsl --with-zlib --enable-pcntl --enable-soap --with-iconv --enable-exif --enable-ftp --with-curl --enable-magic-quotes --enable-cli --enable-fastcgi --enable-discard-path --enable-force-cgi-redirect --enable-cgi
дирек­то­рия для сбор­ки /opt/php5217
в php5.2 mysqlnd не под­дер­жи­ва­ет­ся, поэто­му соби­ра­ем без --with-mysqli
после выпол­ня­ем:

make

make install
Теперь созда­ем оберт­ку (Wrapper) через кото­рую будет идти выпол­не­ние php скриптов:
nano /var/www/user1/php-cgi/php.5217.cgi
[spoiler]#!/bin/sh
PHPRC="/opt/php5217/"
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/php5217/bin/php-cgi[/spoiler]
Даём пра­ва на исполнение:

теперь доста­точ­но в настрой­ках вир­ту­аль­но­го хоста доба­вить сле­ду­ю­щую запись и  будет рабо­тать PHP 5.2.17

[spoiler]<FilesMatch "\.php">
SetHandler application/x-httpd-php5
</FilesMatch>
ScriptAlias /php5217-cgi /var/www/user1/php-cgi/php.5217.cgi
Action application/x-httpd-php5 /php5217-cgi
AddHandler application/x-httpd-php5 .php[/spoiler]

после, не забы­ва­ем пере­за­пус­кать апач
/etc/init.d/httpd restart

Собе­рём php5.3.29

Паке­ты мож­но не ста­вить, так как они уже стоят.
Перей­дём к сбор­ке, дирек­то­рия для сбор­ки /opt/php5329

./configure --prefix=/opt/php5329 --enable-force-cgi-redirect --disable-debug --enable-libxml --with-libxml-dir=/usr/local --enable-reflection --enable-spl --enable-zend-multibyte --with-regex=system --with-tidy --enable-zip --enable-bcmath --enable-calendar --with-curl=shared --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-gettext=shared --enable-mbstring --with-mcrypt=/usr/include --with-mhash=shared --with-mysql --with-libdir=lib --with-openssl --with-pdo-mysql --enable-sockets --with-xsl --with-zlib --enable-pcntl --enable-soap --with-iconv --enable-exif --enable-ftp --with-curl --enable-magic-quotes --enable-cli --enable-fastcgi --enable-discard-path --enable-force-cgi-redirect --enable-cgi --with-mysqli

Если оши­бок нет, выпол­ня­ем make  make install

созда­ём Wrapper  /var/www/user1/php-cgi/php.5329.cgi
Меня­ем вла­дель­ца и права:

chown user1:user1 /var/www/user1/php-cgi/php.5329.cgi
chmod +x /var/www/user1/php-cgi/php.5329.cgi

добав­ля­ем в файл сле­ду­ю­щее содержимое:

[spoiler]#!/bin/sh
PHPRC="/opt/php5329/"
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/php5329/bin/php-cgi[/spoiler]
Теперь в настрой­ках вир­ту­аль­но­го хоста нуж­но доба­вить сле­ду­ю­щую запись:
[spoiler]<FilesMatch "\.php">
SetHandler application/x-httpd-php5
</FilesMatch>
ScriptAlias /php5329-cgi /var/www/user1/php-cgi/php.5329.cgi
Action application/x-httpd-php5 /php5329-cgi
AddHandler application/x-httpd-php5 .php[/spoiler]

ставим PHP7.1.9

cd /opt/alt.php/
wget  http://museum.php.net/php7/php-7.1.9.tar.gz

tar xvfz php-7.1.9.tar.gz

cd php-7.1.9

mkdir /opt/alt.php/php7.1.9/

./configure --prefix=/opt/alt.php/php7.1.9/ --with-config-file-path=/opt/alt.php/php7.1.9/ --with-config-file-scan-dir=/opt/alt.php/php7.1.9/php.d/--with-layout=PHP --with-openssl --with-pear --enable-calendar --with-gmp --enable-exif --with-mcrypt --with-mhash --with-mhash --with-zlib --with-bz2 --enable-zip --enable-ftp --enable-mbstring --with-iconv --enable-intl --with-icu-dir=/usr --with-gettext --with-pspell --enable-sockets --with-openssl -with-curl --with-gd --enable-gd-native-ttf --with-libdir=lib64 --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-webp-dir=/usr --with-freetype-dir=/usr --with-libxml-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-exif --enable-shmop --enable-soap --with-xmlrpc --with-xsl --with-tidy=/usr --enable-pcntl

make && make install

rm -rf /opt/alt.php/php-7.1.9

cp /etc/php.d/*.ini /opt/alt.php/php7.1.9/php.d/

cp /etc/php.ini /opt/alt.php/php7.1.9/php.d/

ставим PHP7.0.9

cd /opt/alt.php/

wget http://museum.php.net/php7/php-7.0.9.tar.gz

tar xvfz php-7.0.9.tar.gz

cd php-7.0.9

mkdir /opt/alt.php/php7.0.9/

./configure --prefix=/opt/alt.php/php7.0.9/ --with-config-file-path=/opt/alt.php/php7.0.9/ --with-config-file-scan-dir=/opt/alt.php/php7.0.9/php.d/ --with-layout=PHP --with-openssl --with-pear --enable-calendar --with-gmp --enable-exif --with-mcrypt --with-mhash --with-mhash --with-zlib --with-bz2 --enable-zip --enable-ftp --enable-mbstring --with-iconv --enable-intl --with-icu-dir=/usr --with-gettext --with-pspell --enable-sockets --with-openssl -with-curl --with-gd --enable-gd-native-ttf --with-libdir=lib64 --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-webp-dir=/usr --with-freetype-dir=/usr --with-libxml-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-exif --enable-shmop --enable-soap --with-xmlrpc --with-xsl --with-tidy=/usr --enable-pcntl

make && make install

rm -rf /opt/alt.php/php-7.0.9

cp /etc/php.d/*.ini /opt/alt.php/php7.0.9/php.d/

cp /etc/php.ini /opt/alt.php/php7.0.9/php.d/

ставим PHP5.6.9

cd /opt/alt.php/

wget http://museum.php.net/php5/php-5.6.9.tar.gz

tar xvzf php-5.6.9.tar.gz

cd php-5.6.9

mkdir /opt/alt.php/php5.6.9/

./configure --prefix=/opt/alt.php/php5.6.9/ --with-config-file-path=/opt/alt.php/php5.6.9/ --with-config-file-scan-dir=/opt/alt.php/php5.6.9/php.d/ --with-layout=PHP --with-openssl --with-pear --enable-calendar --with-gmp --enable-exif --with-mcrypt --with-mhash --with-mhash --with-zlib --with-bz2 --enable-zip --enable-ftp --enable-mbstring --with-iconv --enable-intl --with-icu-dir=/usr --with-gettext --with-pspell --enable-sockets --with-openssl -with-curl --with-gd --enable-gd-native-ttf --with-libdir=lib64 --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-webp-dir=/usr --with-freetype-dir=/usr --with-libxml-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-exif --enable-shmop --enable-soap --with-xmlrpc --with-xsl --with-tidy=/usr --enable-pcntl

make && make install

rm -rf /opt/alt.php/php-5.6.9

cp /etc/php.d/*.ini /opt/alt.php/php5.6.9/php.d/

cp /etc/php.ini /opt/alt.php/php5.6.9/php.d/

ставим PHP5.5.9

wget http://museum.php.net/php5/php-5.5.9.tar.gz

tar xvzf php-5.5.9.tar.gz

cd php-5.5.9

mkdir /opt/alt.php/php5.5.9/

./configure --prefix=/opt/alt.php/php5.5.9/ --with-config-file-path=/opt/alt.php/php5.5.9/ --with-config-file-scan-dir=/opt/alt.php/php5.5.9/php.d/ --with-layout=PHP --with-openssl --with-pear --enable-calendar --with-gmp --enable-exif --with-mcrypt --with-mhash --with-mhash --with-zlib --with-bz2 --enable-zip --enable-ftp --enable-mbstring --with-iconv --enable-intl --with-icu-dir=/usr --with-gettext --with-pspell --enable-sockets --with-openssl -with-curl --with-gd --enable-gd-native-ttf --with-libdir=lib64 --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-webp-dir=/usr --with-freetype-dir=/usr --with-libxml-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-exif --enable-shmop --enable-soap --with-xmlrpc --with-xsl --with-tidy=/usr --enable-pcntl

make && make install

rm -rf /opt/alt.php/php-5.5.9

cp /etc/php.d/*.ini /opt/alt.php/php5.5.9/php.d/

cp /etc/php.ini /opt/alt.php/php5.5.9/php.d/

ставим PHP5.4.9

wget http://museum.php.net/php5/php-5.4.9.tar.gz

tar xvzf php-5.4.9.tar.gz

cd php-5.4.9

mkdir /opt/alt.php/php5.4.9/

./configure --prefix=/opt/alt.php/php5.4.9/ --with-config-file-path=/opt/alt.php/php5.4.9/ --with-config-file-scan-dir=/opt/alt.php/php5.4.9/php.d/ --with-layout=PHP --with-openssl --with-pear --enable-calendar --with-gmp --enable-exif --with-mcrypt --with-mhash --with-mhash --with-zlib --with-bz2 --enable-zip --enable-ftp --enable-mbstring --with-iconv --enable-intl --with-icu-dir=/usr --with-gettext --with-pspell --enable-sockets --with-openssl -with-curl --with-gd --enable-gd-native-ttf --with-libdir=lib64 --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-webp-dir=/usr --with-freetype-dir=/usr --with-libxml-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-exif --enable-shmop --enable-soap --with-xmlrpc --with-xsl --with-tidy=/usr --enable-pcntl --with-vpx-dir=/usr --with-libdir=lib --with-xpm-dir=/usr

make && make install

rm -rf /opt/alt.php/php-5.4.9

cp /etc/php.d/*.ini /opt/alt.php/php5.4.9/php.d/

cp /etc/php.ini /opt/alt.php/php5.4.9/php.d/

ставим PHP5.3.9

wget http://museum.php.net/php5/php-5.3.9.tar.gz

tar php-5.3.9.tar.gz

cd php-5.3.9

mkdir /opt/alt.php/php5.3.9/

./configure --prefix=/opt/alt.php/php5.3.9/ --with-config-file-path=/opt/alt.php/php5.3.9/ --with-config-file-scan-dir=/opt/alt.php/php5.3.9/php.d/ --with-layout=PHP --with-openssl --with-pear --enable-calendar --with-gmp --enable-exif --with-mcrypt --with-mhash --with-mhash --with-zlib --with-bz2 --enable-zip --enable-ftp --enable-mbstring --with-iconv --enable-intl --with-icu-dir=/usr --with-gettext --with-pspell --enable-sockets --with-openssl -with-curl --with-gd --enable-gd-native-ttf --with-libdir=lib64 --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr --with-libxml-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-exif --enable-shmop --enable-soap --with-xmlrpc --with-xsl --with-tidy=/usr --enable-pcntl --with-libdir=lib --with-xpm-dir=/usr

make && make install

rm -rf /opt/alt.php/php-5.3.9

cp /etc/php.d/*.ini /opt/alt.php/php5.3.9/php.d/

cp /etc/php.ini /opt/alt.php/php5.3.9/php.d/

Создаём Wrapper

PHPRC зада­ёт отку­да брать php.ini

5.3

/var/www/user1/php-cgi/wprapper.php5.3.9.cgi

[spoiler]#!/bin/sh
PHPRC=/opt/alt.php/php5.3.9
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/alt.php/php5.3.9/bin/php-cgi[/spoiler]
5.4
 /var/www/user1/php-cgi/wprapper.php5.4.9.cgi
[spoiler]#!/bin/sh
PHPRC=/opt/alt.php/php5.4.9
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/alt.php/php5.4.9/bin/php-cgi[/spoiler]
5.5
 /var/www/user1/php-cgi/wprapper.php5.5.9.cgi
[spoiler]#!/bin/sh
PHPRC=/opt/alt.php/php5.5.9
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/alt.php/php5.5.9/bin/php-cgi[/spoiler]
5.6
 /var/www/user1/php-cgi/wprapper.php5.6.9.cgi
[spoiler]#!/bin/sh
PHPRC=/opt/alt.php/php5.6.9
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/alt.php/php5.6.9/bin/php-cgi[/spoiler]
7.0
 /var/www/user1/php-cgi/wprapper.php7.0.9.cgi
[spoiler]#!/bin/sh
PHPRC=/opt/alt.php/php7.0.9
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/alt.php/php7.0.9/bin/php-cgi[/spoiler]
7.1
 /var/www/user1/php-cgi/wprapper.php7.1.9.cgi
[spoiler]#!/bin/sh
PHPRC=/opt/alt.php/php7.1.9
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/alt.php/php7.1.9/bin/php-cgi[/spoiler]

 

Меняем версию PHP в virtualhost сайта, указав путь до FCGIWrapper :

[spoiler]
<VirtualHost *:8080>
ServerAdmin webmaster@test.t
DocumentRoot /var/www/user1/site/test.t
ServerName test.t
ServerAlias www.test.t
ErrorLog /var/www/user1/logs/test.t.error.log
CustomLog /var/www/user1/logs/test.t.access.log common
<IfModule mod_fcgid.c>
SuexecUserGroup user1 user1
<Directory /var/www/user1/site/test.t>
Options +ExecCGI
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /var/www/user1/php-cgi/wrapper.php7.1.9.cgi .php
Order allow,deny
Allow from all
</Directory>
</IfModule>
</VirtualHost>[/spoiler]