Setting up your first web server on windows with Apache, PHP and MySQL
Published: August 5, 2003
User Rating: 9.1 (514 votes)
Integrating PHP with Apache
There are two ways of integrating PHP with Apache:
-
Server API mode or in-module
In this mode, the php parser is loaded along with Apache, when Apache starts. This is the prefered mode for performance. In case the integration of this fails, you can always go for CGI mode. -
CGI mode
In CGI mode,php.exe
is called everytime a php file has to be executed by Apache. This is slow method of integrating. But is used in certain cases where other modes have failed or in certain highly secure situations.
Following steps are common to both type of integration. Edit the apache's configuration file
httpd.conf
and add the following lines, near the AddType
block:
Now, we also want the php files to also be open as default documents in directories,
find and modify the DirectoryIndex
entry to
you can change the order to your preference.
Following steps are specific to each integration:
-
Server API mode or in-module
- Edit the apache's configuration file
httpd.conf
, and add the following line, near theLoadModule
block.LoadModule php4_module "c:/PHP/sapi/php4apache.dll"
If you have installed Apache version 2.0.xx, then add the following line insteadLoadModule php4_module "c:/PHP/sapi/php4apache2.dll"
- Move the
php4ts.dll
andphp4ts.lib
files from thec:\PHP
to theWINDOWS\System
orWINDOWS\System32
directory. - Copy the
php.ini
file from thec:\PHP
toWINDOWS
directory.
- Edit the apache's configuration file
-
CGI mode
Edit the apache's configuration filehttpd.conf
, and add the following line, near theLoadModule
block.ScriptAlias /php/ "c:/PHP/" Action application/x-httpd-php "/php/php.exe"
About
Amit Arora is web developer with expertise in developing eCommerce enabled websites for the businesses.

Monitored by Site24x7
Uptime