Posted by chris on Wed 26 Apr 2006 at 09:42
The #debian IRC channel on freenode very often sees people who don't know how to get PHP running with Apache. This is nearly always caused by missing packages - particularly the Apache mod_php module.
It is very simple to get a basic setup running - depending on the version of Apache and PHP you want (and are available for your Debian distribution stable/testing/unstable).
Some useful commands for searching for packages are:
apt-cache search apache apt-cache search php
You should decide whether you wish to use Apache 1.x or Apache 2.x - and install the relevant package if you don't already have it present e.g:
apt-get install apache2
Decide if you want PHP4 or PHP5. (PHP5 is available for testing/unstable, but isn't included in the Sarge release). If you chose PHP4 you'd install it with:
apt-get install php4
Once you've installed the appropriate PHP package you'll need to get the matching Apache module - the actual name will depend on what versions you have chosen - but - for this example you'd run:
apt-get install libapache2-mod-php4
Without this last package PHP will not be handled by Apache!
If you install the PHP4 or PHP5 modules for Apache2 then they will automatically enable themselves. If they didn't you would need to manually enable them using the a2enmod tool:
# a2enmod php4 This module is already enabled!
(Or "a2enmod php5" for PHP5.)
There are lots of other PHP libraries for the various dependencies - database interfaces, XML handling etc etc. If you need to do something that PHP doesn't cope with - try using the "apt-cache search" command to see if there is a module for it.
Note - this is not meant to be an exhaustive guide - just something that we can point people to as a starting point :)