This document explains how to add PHP scripting capabilities to the Apache web server on an Elemental Linux Server (ELS) system.
These instructions assume that you already have a working Apache web server installed. If you do not, please see the ELS Howto: Apache Web Server before continuing.
You will also need to have the ELS 'Extra Applications' CD-ROM mounted on /media/cdrom or be able to download packages from the ELS distribution site.
The following instructions describe how to install PHP using the ELS CD-ROM.
The following example shows how you would install php-5.2.6 for httpd-2.2.9 using the ELS CD-ROM:
cd / tar -zxf /media/cdrom/extra/php-5.2.6.i586.tar.gz cd /opt/httpd-2.2.9/modules ln -s ../../php-5.2.6/modules/libphp5.so cd /opt/bin ln -s ../php-5.2.6/bin/* .
After installing PHP you will need to adjust the httpd configuration as well as supplying a configuration file for PHP.
The latest recommended php.ini file may be found from the PHP project's CVS repository or by looking in the source package for PHP.
The following example shows how to modify httpd.conf and how to fetch the recommended php.ini file from the PHP project's CVS site.
vi /etc/opt/httpd/httpd.conf LoadModule php5_module modules/libphp5.so AddHandler php5-script .php AddType application/x-httpd-php .php DirectoryIndex index.php index.html mkdir /etc/opt/php cd /etc/opt/php wget http://svn.php.net/viewvc/php/php-src/trunk/php.ini-production?revision=324317&view=co mv php.ini-production?view\=co php.ini /etc/init.d/httpd restart
Check the php installation by trying a simple php test script.
The following example shows a successful test using Lynx as the web browser.
login: joe password: $ lynx -dump http://127.0.0.1/info.php | head [1]PHP Logo PHP Version 5.2.6 System Linux els.mynetwork.lan 2.6.25.10 #5 Sun Aug 24 20:48:35 CDT 2008 i686 Build Date Aug 10 2008 16:17:45 Configure Command '/usr/src/php-5.2.6/configure'
If you cannot view the info.php page, here are some things to try.
Help with php.ini directives can be found at: http://us.php.net/manual/en/ini.php.