Apache PHP

Keary Suska yellowdog-general@lists.terrasoftsolutions.com
Fri May 17 18:52:00 2002


on 5/17/02 6:25 PM, paulguba@comcast.net purportedly said:

> Has anyone enabled PHP in Apache.  Not sure if I need to recompile Apache or
> just activate a module.  PHP4 is installed on my machine but not sure if it
> was installed as a module or CGI it can be either according to a tutorial I'm
> reading.  I have added AddType application/x-httpd-php4 .php4 to my virtual
> server directive but not sure if this is correct as the tutorial refers PHP3.
> It also seems that the module is on by default on the server but my scripts
> don't seem to work.

PHP can either be compiled into Apache or as a loadable (.so). If you are
using stock RPMs, I don't think it will be compiled in unless the Apache RPM
has "PHP" in the name. Even then, I can't say for sure, as I never use RPM
for Apache/PHP.

If PHP is installed as a loadable, you will see a file called "libphp4.so"
under the libexec directory of the Apache installation directory. You may
have to do an RPM -ql to find out where this is, as Apache RPMs tend to
install in unpreferable locations.

If you find this, then your httpd.conf file needs LoadModule and AddModule
directives. There should be examples in your conf of this. On my system, PHP
is loaded last but before mod_ssl. Like this:

    LoadModule php4_module  libexec/libphp4.so
.
.
    AddModule mod_php4.c

Then you need to tell Apache how to recognize PHP scripts. Typically, you
do:

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

If PHP is compiled in, you only need the AddModule and AddType directives.
If you have these, and PHP still doesn't work, it is likely not compiled in.
You could try running apachectl with either status or fullstatus for more
info on available modules, IIRC.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"