Getting PHP running with Apache

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 :)

 

 


Posted by Anonymous (193.195.xx.xx) on Wed 26 Apr 2006 at 16:20
What about running PHP as a CGI, not as a module?

[ Parent | Reply to this comment ]

Posted by Steve (212.20.xx.xx) on Wed 26 Apr 2006 at 16:57
[ View Steve's Scratchpad | View Weblogs ]

Probably best to not cover it in a general introduction like this.

Still if you're interested in running PHP as CGI then you start by looking at this previous article on using suphp + php-cgi.

Steve

[ Parent | Reply to this comment ]

Posted by mvanbaak (80.126.xx.xx) on Thu 27 Apr 2006 at 00:23
PHP5 for sarge can be found on http://www.dotbeb.org
I use it on all my debian sarge installs. It's working great.

[ Parent | Reply to this comment ]

Posted by mvanbaak (80.126.xx.xx) on Thu 27 Apr 2006 at 00:25
Hhmm, remind me to not comment after 1 AM ;) The url to dotdeb should be http://www.dotdeb.org/

[ Parent | Reply to this comment ]

Posted by Anonymous (2001:0xx:0xx:0xxx:0xxx:0xxx:xx) on Fri 24 Sep 2010 at 10:34
"Note - this is not meant to be an exhaustive guide - just something that we can point people to as a starting point :)"

That's exactly what i needed. THX a lot !

[ Parent | Reply to this comment ]

Posted by Anonymous (212.110.xx.xx) on Wed 22 Jan 2014 at 13:15
Great info! THX!
P.S. I was looking for this solution for 2 days...:) Thanks a lot!

[ Parent | Reply to this comment ]

Sign In

Username:

Password:

[Register|Advanced]

 

Flattr

 

Current Poll

What do you use for configuration management?








( 496 votes ~ 5 comments )