Compile PHP-5.6 with Apache Worker support

This entry is part 2 of 5 in the series: How to compile PHP from the source code

A look at PHP-5.6

The Apache Worker implements a hybrid multi-process multi-threaded server allowing to serve a large number of requests per second using fewer resources than Prefork module then is a good option if your site is under heavy load. Other advantages of using Apache Worker is that it allows to create multi-threaded applications making use of pthreads extension

Note: while the PHP development team does not recommend use PHP with Apache threaded modules since some extensions are not "thread safe" and therefore may have a wrong behavior I have successfully tested it with 2 applications used on a large scale: WordPress and phpMyAdmin.

Download php-5.6.4

wget http://us1.php.net/distributions/php-5.6.4.tar.xz

Unpack

tar xJvf php-5.6.4.tar.xz

Download and run the script to install dependencies

$ wget --no-check-certificate https://raw.githubusercontent.com/yoander/sysadmin/master/shscript/php-dev-install-dep.sh && 
        chmod a+x -c php-dev-install-dep.sh && 
        ./php-dev-install-dep.sh apache-worker

Download script to compile php

$ wget --no-check-certificate https://raw.githubusercontent.com/yoander/sysadmin/master/shscript/php-build.sh && 
        chmod a+x -c php-build.sh

Compile php

$./php-build.sh -at php-5.6.4

where -a = support for apache, -t = support multithreading (thread safe)

Install

$ cd php-5.6.4 && sudo make install

Create php configuration file

Development

sudo cp -v php.ini-development /etc/php/php.ini

Production

sudo cp -v php.ini /etc/php/php.ini

Activate OpCache

If you use Xdebug then OpCache should be loaded first

$ sudo bash -c 'echo "zend_extension=opcache.so" > /etc/php/conf.d/20-opcache.ini'

Restart the Apache

sudo service apache2 restart

We check

$ firefox http://localhost/info.php



Leave a Comment

Your email address will not be published. Required fields are marked *