Setting up your first web server on windows with Apache, PHP and MySQL
Published: August 5, 2003
User Rating: 9.2 (362 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.exeis 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 theLoadModuleblock.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.dllandphp4ts.libfiles from thec:\PHPto theWINDOWS\SystemorWINDOWS\System32directory. - Copy the
php.inifile from thec:\PHPtoWINDOWSdirectory.
- Edit the apache's configuration file
-
CGI mode
Edit the apache's configuration filehttpd.conf, and add the following line, near theLoadModuleblock.ScriptAlias /php/ "c:/PHP/" Action application/x-httpd-php "/php/php.exe"


