Installing Php from source — tutorial

By | July 20, 2009

This is a simple tutorial, on how to download the php source, compile and get it installed on your system

Lets start by downloading the latest source from the php site

cd /tmp
Tar –xzvf php-5.2.10.tar.gz
cd php-5.2.10

locate where your apxs binary is installed, ex this is a part of the apache webserver

[root@testsrv ~]# locate apxs

If you installed any of the other apps from source then you must select the correct paths again as above and edit the command below

Now we start configuring the installer

./configure --with-apxs2=/sw/pkg/apache/bin/apxs --with-mysql=/usr/include/mysql/ --with-gd --with-config-file-path=/etc/ --with-jpeg-dir=/usr/local/lib/

When completed, and if there are no errors, then type in the following

Then once the compiling has been completed
make install

Congrats! you have just installed php on your system

To Check that all is correct type in
php --version

If you get something similar to this, then you’re good to go 🙂

[root@testsrv ~]# php --version
PHP 5.2.10 (cli) (built: Jul 16 2009 18:55:27)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
[root@testsrv ~]#

Php should have edited your httpd.conf file automatically according to the information,
you have supplied, if not add the following lines to your httpd.conf

LoadModule php5_module modules/

# Set it to handle the files
AddType application/x-httpd-php .php5
AddType application/x-httpd-php-source .phps

AddDirectoryIndex index.php index.phtml

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.