1. In order to enable php engine in apache, you should make sure php is installed in the system first. Then refer following steps :
locate libphp5.so
In most of cases, libphp5.so will be present inside /etc/httpd/modules
2. Add following in httpd.conf :
------------------
# Use for PHP 5.x:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php
AddType text/html .php
# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps
------------------
OR
-----------------
LoadModule php5_module modules/libphp5.so
# Use of the "ZTS" build with worker is experimental, and no shared
# modules are supported.
LoadModule php5_module modules/libphp5-zts.so
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
-----------------
3. Restart apache.
Testing :
$ httpd -t
Create a php file inside web directory. Put the following content in that file like :
vi info.php
--------
--------
Then access the file through browser like http://localhost/info.php. If it shows all the enables php directives or modules then php works fine.
locate libphp5.so
In most of cases, libphp5.so will be present inside /etc/httpd/modules
2. Add following in httpd.conf :
------------------
# Use for PHP 5.x:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php
AddType text/html .php
# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps
------------------
OR
-----------------
LoadModule php5_module modules/libphp5.so
# Use of the "ZTS" build with worker is experimental, and no shared
# modules are supported.
LoadModule php5_module modules/libphp5-zts.so
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
-----------------
3. Restart apache.
Testing :
$ httpd -t
Create a php file inside web directory. Put the following content in that file like :
vi info.php
--------
--------
Then access the file through browser like http://localhost/info.php. If it shows all the enables php directives or modules then php works fine.