apt-get update
apt-get ugrade
apt-get install build-essential
This packages contain a lot of necessary tools like a c and a c++ compiler, make and other libs.
apt-get install git
apt-get install lamp-server
The installation will ask you to choose a password for the mysql root user. Once finished, open a tab in your browser to http://localhost
You should see a page with the heading "It Works!"
cd /opt
git clone git://git.code.sf.net/p/phpfarm/code phpfarm
Before compiling any PHP version, setup the options you need
vim /opt/phpfarm/src/options.sh
Mine looks like this:
#!/bin/bash
# You can override config options very easily.
# Just create a custom options file; it may be version specific:
# - custom-options.sh
# - custom-options-5.sh
# - custom-options-5.3.sh
# - custom-options-5.3.1.sh
#
# Don't touch this file here - it would prevent you to just "svn up"
# your phpfarm source code.
version=$1
vmajor=$2
vminor=$3
vpatch=$4
#gcov='--enable-gcov'
configoptions="\
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-bcmath \
--with-curl \
--with-png \
--with-gd \
--enable-cli \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--with-mcrypt \
--enable-pcntl \
--enable-soap \
--enable-sockets \
--enable-sqlite-utf8 \
--enable-wddx \
--enable-zip \
--with-openssl \
--with-zlib \
--with-gettext \
--with-pear \
--with-iconv \
--with-zlib \
--with-mime-magic \
--with-mhash \
--enable-bcmath \
--enable-fastcgi \
--enable-force-cgi-redirect \
--enable-gd-native-ttf \
$gcov"
echo $version $vmajor $vminor $vpatch
custom="custom-options.sh"
[ -f $custom ] && source "$custom" $version $vmajor $vminor $vpatch
custom="custom-options-$vmajor.sh"
[ -f $custom ] && source "$custom" $version $vmajor $vminor $vpatch
custom="custom-options-$vmajor.$vminor.sh"
[ -f $custom ] && source "$custom" $version $vmajor $vminor $vpatch
custom="custom-options-$vmajor.$vminor.$vpatch.sh"
[ -f $custom ] && source "$custom" $version $vmajor $vminor $vpatch
cd /opt/phpfarm/src
./compile 5.5.0
If the compilation fails, just install the libraries that caused the error. In my case I had to install these packages:
apt-get install libxml2 libxml2-dev libssl-dev libcurl4-openssl-dev pkg-config \
libcurl4-gnutls-dev libjpeg-dev libpng12-dev libmysqlclient-dev
./compile 5.5.0
To verify the installation
cd /opt/phpfarm/inst/bin
./php-5.5.0 --version
apt-get install libapache2-mod-fastcgi apache2-mpm-worker apache2-suexec
a2enmod actions fastcgi suexec
service apache2 restart
This will disable mod_php.
Edit the /etc/apache2/apache2.conf, add these lines before the includes
FastCgiServer /var/www/cgi-bin/php-cgi-5.5.0
ScriptAlias /cgi-bin-php/ /var/www/cgi-bin/
Now create the file /var/www/cgi-bin/php-cgi-5.5.0, with this content
#!/bin/sh
version="5.5.0"
PHPRC="/etc/php5/cgi/${version}/"
export PHPRC
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/phpfarm/inst/bin/php-cgi-${version}
Make the file executable
chmod +x /var/www/cgi-bin/php-cgi-5.5.0
Configure a VirtualHost to use the php version we just configured eg: /etc/apache2/sites-available/example.conf
<VirtualHost *:80>
ServerName example.dev
DocumentRoot /var/www/example/
<Directory "/var/www/example">
AddHandler php-cgi .php
Action php-cgi /cgi-bin-php/php-cgi-5.5.0
<FilesMatch "\.php$">
SetHandler php-cgi
</FilesMatch>
</Directory>
</VirtualHost>
Enable the site
a2ensite example.conf
Add the server to /etc/hosts
127.0.0.1 example.dev
Restart apache
service apache2 restart
I got an error at this point. Apache was complaining about mod_fast already defined. To fix the problem opne this file /etc/aoache2/mods-available/fastcgi.conf and comment out the last line inside the IfModule block
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
#FastCgiWrapper /usr/lib/apahce2/suexec
#FastCgiIpcDir /var/lib/apache2/fastcgi
</IfModule>
Then restart apache again
service apache2 restart
If you don't get any error you will find a working installation of PHP5.5.0 at http://example.dev :)