Building PHP 5.4 From Source On Debian Squeeze
Version 1.0.0
For ISPConfig: 3.0.5.1
Author: Michel Käser <info [at] rackster [dot] ch>
This tutorial describes how you can build PHP 5.4 from source on Debian Squeeze. Later on, we will install more modules through PECL and add it as an additional PHP version to ISPConfig's dropdown.
At the end you will have a fully function PHP 5.4 installation which is selectable within the ISPConfig interface and a .deb package than can be used on other server as well.
I do not issue any guarantee that this will work for you!
1 Requirements
To follow this tutorial you will need the following:
- a perfect server running Debian Squeeze
- an ISPConfig (3.0.5 or later) installation
- about 45 minutes time to read carefully
2 Preliminary Notes
I highly recommend to compile the packages on a separate server, since it requires a lot of packages to be installed we don't need otherwise. If you do not have more than one server, it might still be smart to rent a cheap VPS somewhere for a few hours/days.
The configure command/parameters we're going to use are as near as possible to the ones that are used to build the regular Debian PHP packages, which are available from the official repositories.
Last but not least, most of these information can be found in the ISPConfig Manual - you know what I'm trying to tell you, don't you? ;)
3 Prerequisites
(on separate server)
Before we can start with the build process, you should install some additional packages. A few of them are just because I like them better (e.g. nano):
apt-get -y install nano build-essential checkinstall zip
checkinstall will help us to create .deb packages. Check the source from Credits section if you'd like to know more about it.
4 Downloading PHP
(on separate server)
Before we start downloading and compiling our custom PHP version, we're going to create some directories:
mkdir -p /opt/php/5.4.12
mkdir /usr/local/src/php5-build
and start downloading the PHP sources as soon as done:
cd /usr/local/src/php5-build
wget http://ch1.php.net/distributions/php-5.4.12.tar.gz
tar -xzvf php-5.4.12.tar.gz
cd php-5.4.12/
Since we need to fetch PHP's dependencies, make sure you have a deb-src line in your /etc/apt/sources.list:
nano /etc/apt/sources.list
deb-src http://ftp.debian.org/debian squeeze main contrib non-free
and update the package cache:
apt-get update
5 Building PHP
(on separate server)
Following the steps above, we prepared our system to be ready to compile. Now, first, we have to fetch/install the dependencies:
apt-get build-dep php5
and install a handful other packages:
apt-get -y install libfcgi-dev libfcgi0ldbl libjpeg62-dbg libmcrypt-dev libssl-dev
Finally, we are ready to build PHP. As usual, the first step is to fire the configure command. To get a list of all available options, use ./configure --help:
./configure \
--prefix=/opt/php/5.4.12 \
--with-zlib-dir \
--with-freetype-dir \
--enable-cgi \
--enable-mbstring \
--with-libxml-dir=/usr \
--enable-soap \
--enable-calendar \
--with-curl \
--with-mcrypt \
--with-zlib \
--with-gd \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--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 \
--with-libdir=lib64 \
--with-libxml-dir=/usr \
--enable-exif \
--enable-dba \
--with-gettext \
--enable-shmop \
--enable-sysvmsg \
--enable-wddx \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--enable-bcmath \
--enable-ftp \
--enable-intl \
--with-pspell
If everything went well and you did not get any error messages, continue with:
make
to actually compile.
6 Creating a package
(on separate server)
Normally, we would now use make install to install the compiled sources on the system. However, since we'd like to have a .deb file, we make use of the tool checkinstall:
checkinstall -D make install
Right at the beginning it will ask you to create docs -> choose yes (y) and enter a short summary of your package, e.g.
PHP 5.4.12 compiled from source on Debian Squeeze (6.0.7) amd64 architecture
The following screen allows you to manipulate a lot of other values as well. I recommend to change at least:
0: e.g. Rackster Internet Services <admin@rackster-server.ch>
2: php-5.4.12
11: php-5.4.12
Press enter when done. checkinstall will then generate the package for you.
The resulting package however is missing the .ini files, so we create a .zip archive:
zip /root/php-5.4.12.zip *.deb *.ini-*
Done. Great!
7 Installing the package
Everything up to here was done (or should have been done) on it's own server. This part takes place on your ISPConfig system. Make sure you have transfered/copied the resulting .zip file over here.
Unzip the archive:
unzip php-5.4.12.zip
install the package:
dpkg -i php-*.deb
and copy the .ini files:
cp *.ini-* /opt/php/5.4.12/lib
cp /opt/php/5.4.12/lib/php.ini-production /opt/php/5.4.12/lib/php.ini
8 Adding additional modules
Other than the PHP version installed through the package manager of your choice, our custom build will not be able to use modules installed through e.g. apt - but there's an easy alternative.
PEAR and PECL are like package managers for PHP - install them:
apt-get -y install php-pear
and change directory:
cd /opt/php/5.4.12/etc
8.1 Installing APC
pecl -C ./pear.conf update-channels
pecl -C ./pear.conf install apc
Accept default values everywhere. When done, we simply have to add it to our php.ini:
nano /opt/php/5.4.12/lib/php.ini
extension=apc.so
8.2 Installing uploadprogress
pecl -C ./pear.conf install uploadprogress
Accept default values everywhere. When done, we simply have to add it to our php.ini:
nano /opt/php/5.4.12/lib/php.ini
extension=uploadprogress.so
9 Adding PHP to ISPConfig
In ISPConfig 3.0.5, 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. 5.4.12) - this PHP version will be listed under this name in the website settings in ISPConfig:
Server: Select the server where the PHP version is installed. Client: If this PHP version should be available for just for one specific client, select that client here. Otherwise, this PHP version will be available for all clients. PHP Name: 5.4.12
Go to the FastCGI Settings tab and fill out the fields as follows:
Path to the PHP FastCGI binary: /opt/php/5.4.12/bin/php-cgi Path to the php.ini directory: /opt/php/5.4.12/lib
10 Links / Credits
- http://www.ispconfig.org/ispconfig-3/ispconfig-3-manual/
- http://www.falkotimme.com/howtos/checkinstall/index.php
- https://www.rackster.ch/