Добавить в FacebookДобавить в Google BookmarksДобавить в TwitterДобавить в OdnoklassnikiДобавить в Vkcom

I will create, perhaps, the next record in order not to forget. Recently I had a need to install and run several versions of php under one apache server. Actually it was necessary to run a site that could work under php 5.6 and did not run under the default php 7.0. I looked at the various options and I was given the launch of the old version of php 5.6 via fastcgi. So, I already have the apache 2.4 server installed and php 7.0 installed. Let's start with downloading and building php 5.6. Run the necessary commands:

apt-get -y install build-essential libfcgi-dev libfcgi0ldbl libjpeg62-dbg libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libfreetype6-dev libkrb5-dev libpq-dev libxml2-dev libxslt1-dev pkg-config

mkdir /opt/php-5.6.30 # create a folder in which will be compiled version of php

mkdir /usr/local/src/php5-build # create a source folder

cd /usr/local/src/php5-build

wget http://de.php.net/get/php-5.6.30.tar.bz2/from/this/mirror -O php-5.6.30.tar.bz2

tar jxf php-5.6.30.tar.bz2

cd php-5.6.30/

then configure and compile php5.6.30.

./configure --prefix=/opt/php-5.6.30 --with-config-file-path=/opt/php-5.6.30 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl=/usr/bin --with-mcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-pdo-mysql --with-mysqli --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --enable-ftp --with-kerberos --with-gettext --enable-cli --enable-fastcgi --enable-discard-path --enable-force-cgi-redirect --enable-cgi

compile and install 

make

make install

At the end of the run, you will have a compiled version of php-5.6.30 in the /opt/php-5.6.30/ directory.

Next, you need to install the module for apache.

apt-get install libapache2-mod-fastcgi

and run it and some other modules

a2enmod fastcgi

a2enmod actions

Next, we edit the configuration file /etc/apache2/mods-enabled/fastcgi.conf (cite the contents).

<IfModule mod_fastcgi.c>
  AddHandler fastcgi-script .fcgi
  #FastCgiWrapper /usr/lib/apache2/suexec
  FastCgiIpcDir /var/lib/apache2/fastcgi
  FastCgiServer /usr/lib/cgi-bin/php56-cgi -idle-timeout 240
</IfModule>

 

Then we create a wrapper through which the php scripts will be executed.

vi /usr/lib/cgi-bin/php56-cgi

#!/bin/sh
PHPRC="/opt/php-5.6.30/"
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/php-5.6.30/bin/php-cgi
 
Add permitions to execute.
sudo chmod +x /usr/lib/cgi-bin/php56-cgi
 
Create an apache configuration file with the settings of the php scripts handler.
 
vi /etc/apache2/php56.conf
 
<Directory /usr/lib/cgi-bin/>
LogLevel warn
Options -Indexes +FollowSymLinks +ExecCGI
Require all granted
</Directory>
<FilesMatch "\.php">
SetHandler application/x-httpd-php5
</FilesMatch>
ScriptAlias /php56-cgi /usr/lib/cgi-bin/php56-cgi
Action application/x-httpd-php5 /php56-cgi
AddHandler application/x-httpd-php5 .php
 
It remains to create a configuration file for the virtual host and include php56.conf.
 
vi /etc/apache2/sites-available/test.conf
 
<VirtualHost *:80>
        
        Include php56.conf
 
        ServerName test.local
 
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/test
        <Directory /var/www/test>
        Options  Indexes FollowSymLinks
        AllowOverride all
        Require all granted
        </Directory>               
 
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined        
</VirtualHost>
 
Add this virtual host to the configuration apache
 
a2ensite test.conf
 
and restart the service
 
service apache2 restart
 
To verify, create a file 
 
vi /var/www/test/phpinfo.php
 
<?php
phpinfo();
?>
 
We have one version of php on one site.
 
 
and another version on another site.
 
 

Good Luck.

Author: Darkeye.  

Еще интересное в сети.

  

 

Похожие материалы

Go to the article feed

Добавить комментарий