Tuesday, January 17, 2012

Configuring php handler as Apache module


Edit the apache configuration file as follows
vi /etc/httpd/conf/httpd.conf

####   PHP as Apache Module
LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so
AddType application/x-httpd-php .php

Restart the apache
/etc/init.d/httpd restart

How to check:

create an info.php file
vi info.php
<?php
phpinfo();
?>

http://domain.com/info.php

Check the Server API field
If  php is handled by Apache module it will show as
Server API  :  Apache 2.0 Handler

If  php is handled by FastCGI it will show as
Server API  : CGI/FastCGI

Configuring php handler as FastCGI


Edit the apache configuration file as follows
vi /etc/httpd/conf/httpd.conf

####    PHP as fast cgi
AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php.fcgi
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

Restart the apache
 /etc/init.d/httpd restart

How to check:

Create an info.php file
vi info.php
<?php
phpinfo();
?>

http://domain.com/info.php
Check the Server API field

If  php is handled by Apache module it will show as
Server API  :  Apache 2.0 Handler

If  php is handled by FastCGI it will show as
Server API  : CGI/FastCGI