How to install PHP 5.1.2 and Apache 1.3.34

Sven Hermans

03 Mar 2006

Any comments are welcome, for contacting me use

Table of Contents

1. info
2. Download
3. Configure Apache
4. Configure and Compile PHP 5
5. Compiling Apache with PHP 5
6. Test your PHP Setup!
7. Enabling xdebug

1. info

This document helps you with the installation of the Apache webserver with PHP 5 on Linux.

It is assumed you already have MySQL installed.

2. Download

Put them in a directory of choice, ie. ~/src, and unzip the files.

~/src$ tar -zxvf apache_1.3.34.tar.gz
~/src$ tar -zxvf php-5.1.2.tar.gz

3. Configure Apache

Before compiling PHP, configure Apache. This needs to be done first, because PHP needs the Apache configuration to install.

$ cd apache_1.3.34
$ ./configure --prefix=/usr/local/apache

This won't take long to run. Don't make & make install yet, this will be done later.

4. Configure and Compile PHP 5

This installation of PHP will need some extra features, like maybe SOAP or XML functionality. For XML you need libxml2-dev. On a Debian machine this can be installed with:

# apt-get install libxml2-dev
# apt-get install openssl libssl-dev

Even if you already had that library, it wouldn't hurt to see if it has an upgrade available.

cd into the php directory:

$ cd ../php-5.1.2

Configure PHP with GD, XML, OpenSSL .. and more!

$ ./configure \
--with-apache=../apache_1.3.34 \
--with-mysql=/usr/local/mysql \
--with-gd \
--with-jpeg-dir \
--enable-jpeg \
--with-xml \
--with-zlib=/usr \
--with-mcrypt \
--with-dom-xslt \
--with-dom-exslt \
--enable-gd-native-ttf \
--with-ttf \
--with-openssl \
--enable-ftp \
--enable-png \

If you get an error, it's most likely you are missing some development libraries. If you get a "Thank you for using PHP." message, you can continue...

# make
# make install
# cp php.ini-dist /usr/local/lib/php.ini

5. Compiling Apache with PHP 5

Finally, we can start compiling Apache.

# cd ../apache_1.3.34

# ./configure \
--prefix=/usr/local/apache \
--activate-module=src/modules/php5/libphp5.a \

# make
# make install

When this is done, make sure that files with a php extension are executed by PHP

To httpd.conf , add:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Start Apache:

/usr/local/apache/bin/apachectl start

6. Test your PHP Setup!

Create a info.php page in your web directory, (usually /usr/local/apache/htdocs/)

print phpinfo();

Go to http://localhost/info.php and you should see a PHP information page.

7. Enabling xdebug

If you want good debugging features, it can be a good idea to install xdebug. You get it at

After extracting xdebug-2.0.0beta5.tgz in the ~/src directory, the only thing you have to do is follow the steps in the provided README file.

Restart Apache, check your PHP version again, and you will see that Xdebug is enabled.

$ php -v
PHP 5.1.2 (cli) (built: Mar  2 2006 23:02:55)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
    with Xdebug v2.0.0beta5, Copyright (c) 2002, 2003, 2004, 2005, by Derick Rethans

Now you have fancy var_dump output at least. Additionally you can install a debugclient, that can be run from a shell.

$ cd xdebug-2.0.0beta5/debugclient
$ ./configure --with-libedit
# make
# make install

Add the following to your php.ini

xdebug.remote_enable = On
xdebug.remote_host = "localhost"
xdebug.remote_handler = "dbgp"

Restart Apache (again..), run the debugclient

$ debugclient
Xdebug Simple DBGp client (0.9.1)
Copyright 2002-2005 by Derick Rethans.
- libedit support: enabled

Waiting for debug server to connect.

Go to http://localhost/info.php?XDEBUG_SESSION_START=xtest

<init fileuri="file:///usr/local/apache/htdocs/info.php" language="PHP" protocol_version="1.0" appid="29893" idekey="xtest">
	<engine version="2.0.0beta5">Xdebug</engine>
	<author>Derick Rethans</author>
	<copyright>Copyright (c) 2002-2005 by Derick Rethans</copyright>

From here on (the cmd), you are able to use the DBGp commands. But that is beyond the scope of this installation guide.