Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

How to install PHP 5.6 as additional PHP-FPM & FastCGI for ISPConfig 3.1 o ...

$
0
0

This tutorial shows how to build php 5.6 as a PHP-FPM and a FastCGI version on Ubuntu 16.04 (Xenial Xerus). Ubuntu 16.04 ships with PHP 7 by default but there are still many websites out there that don't support PHP 7. This tutorial will show you how to install PHP 5.6 as additional PHP version on Ubuntu 16.04 so that you can switch between both versions for each website individually in ISPConfig.

1 Preliminary Note

I will install PHP 5.6 in /opt so that the main PHP 7 of Ubuntu is not affected and PHP 7 will stay the default PHP of our server while PHP 5.6 is available as option in ISPConfig (website settings). Please note that PHP-FPM can be used on both Apache and Nginx serverswhile FastCGI is available only for Apache servers in ISPConfig.

With older PHP versions, PHP-FPM and FastCGI had beenmutually exclusive so that an FPM and FastCGI binary had to be build separately. With PHP 5.6,a singlebinary that supports FPM and FCGI mode can be build.

2 CompilePHP 5.6 with PHP-FPM and Fastcgi

Install the prerequisites to build PHP 5.6, wget and the nano editor that I will use to edit the config files:

apt-get install build-essential wget nano

apt-get install 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

ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a

(The last command is needed if you build PHP with --with-imap , because otherwise ./configure will stop with the following error:

checking for crypt in -lcrypt... yes

configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.

[emailprotected]

:/usr/local/src/php5-build/php-5.6.25#

)

Download and extract PHP 5.6 from php.net:

mkdir /opt/php-5.6.25

mkdir /usr/local/src/php5-build

cd /usr/local/src/php5-build

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

tar jxf php-5.6.25.tar.bz2

cd php-5.6.25/

Configure and build PHP 5.6.25 as follows (you can adjust the ./configure command to your needs, take a look at

./configure --help

to see all available options; if you use a different ./configure command, it is possible that additional libraries are required, or the build process will fail):

./configure --prefix=/opt/php-5.6.25 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --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 --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-gettext --with-xmlrpc --with-xsl --with-kerberos--enable-fpm

The above string is just one long command, do not add any line breaks. The last switch ( --enable-fpm ) makes sure this PHP version will work with PHP-FPM.

make

make install

Copy php.ini and php-fpm.conf to the correct locations:

cp /usr/local/src/php5-build/php-5.6.25/php.ini-production /opt/php-5.6.25/lib/php.ini

cp /opt/ php-5.6.25 /etc/php-fpm.conf.default /opt/ php-5.6.25 /etc/php-fpm.conf

Create the pool file directory php-fpm.d.

mkdir/opt/php-5.6.25/etc/ php-fpm.d

Open /opt/ php-5.6.25 /etc/php-fpm.conf and adjust the following setting (remove the ; in front of the pid line):

nano /opt/ php-5.6.25 /etc/php-fpm.conf

[...]
pid = run/php-fpm.pid
[...]
user = www-data
group = www-data
[...]
listen = 127.0.0.1:8999
[...]
include=/opt/php-5.6.25/etc/php-fpm.d/*.conf 3 Create the systemd unit file

Ubuntu 16.04 uses systemd as init system. I will create a systemd unit file to be able to start / stop and restart the PHP-FPM service.

nano/lib/systemd/system/ php-5.6.25 -fpm.service

with the following content:

[Unit]
Description=The PHP 5.6 FastCGI Process Manager
After=network.target
[Service]
Type=simple
PIDFile=/opt/php-5.6.25/var/run/php-fpm.pid
ExecStart=/opt/php-5.6.25/sbin/php-fpm --nodaemonize --fpm-config /opt/php-5.6.25/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target

Enable the service and reload systemd:

systemctl enable php-5.6.25-fpm.service

systemctl daemon-reload

Finally start PHP-FPM.

systemctl start php-5.6.25 -fpm.service

To enable the Zend OPcache, open /opt/ php-5.6.25 /lib/php.ini ...

nano /opt/ php-5.6.25 /lib/php.ini

... and add the following line at the end:

[...]
zend_extension=opcache.so

Test the PHP version:

cd/opt/ php-5.6.25 /bin

./php --version

The output should be similar to this screenshot.


How to install PHP 5.6 as additional PHP-FPM & FastCGI for ISPConfig 3.1 o ...
4 Enable PHP 5.6 in ISPConfig

In ISPConfig 3.1, you can configure the new PHP version under System > Additional PHP Versions . On the Name tab, you just fill in a name for the PHP version (e.g. PHP 5.6.25 ) - this PHP version will be listed under this name in the website settings in ISPConfig:


How to install PHP 5.6 as additional PHP-FPM & FastCGI for ISPConfig 3.1 o ...

Go to the FastCGI Settings tab and fill out the fields as follows:

Path to the PHP FastCGI binary:/opt/php-5.6.25/bin/php-cgi
Path to the php.ini directory: /opt/php-5.6.25/lib
How to install PHP 5.6 as additional PHP-FPM & FastCGI for ISPConfig 3.1 o ...

Then gto the PHP-FPM Settings taband fill out the fields as follows:

Path to the PHP-FPM init script:php-5.6.25-fpm
Path to the php.ini directory: /opt/php-5.6.25/lib
Path to the PHP-FPM pool directory: /opt/php-5.6.25/etc/php-fpm.d
How to install PHP 5.6 as additional PHP-FPM & FastCGI for ISPConfig 3.1 o ...
5Links PHP: http://www.php.net/ ISPConfig: http://www.ispconfig.org/ Ubuntu: http://www.ubuntu.com/

Viewing all articles
Browse latest Browse all 11063

Trending Articles