Setting up your first web server on windows with Apache, PHP and MySQL
by Amit Arora
Published: August 5, 2003
User Rating: 9.1 (514 votes)

Page Page » 1 2 3 4 5 6 7 8

Integrating PHP with Apache

There are two ways of integrating PHP with Apache:

  1. 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.

  2. 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:

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

Now, we also want the php files to also be open as default documents in directories, find and modify the DirectoryIndex entry to

DirectoryIndex index.phtml index.php index.php3 index.html index.htm

you can change the order to your preference.

Following steps are specific to each integration:

  1. Server API mode or in-module

    1. Edit the apache's configuration file httpd.conf, and add the following line, near the LoadModule block.
      LoadModule php4_module "c:/PHP/sapi/php4apache.dll"

      If you have installed Apache version 2.0.xx, then add the following line instead
      LoadModule php4_module "c:/PHP/sapi/php4apache2.dll"

    2. Move the php4ts.dll and php4ts.lib files from the c:\PHP to the WINDOWS\System or WINDOWS\System32 directory.
    3. Copy the php.ini file from the c:\PHP to WINDOWS directory.

  2. CGI mode
    Edit the apache's configuration file httpd.conf, and add the following line, near the LoadModule block.

    ScriptAlias /php/ "c:/PHP/" Action application/x-httpd-php "/php/php.exe"
Page Page » 1 2 3 4 5 6 7 8

About

Amit Arora is web developer with expertise in developing eCommerce enabled websites for the businesses.

Contact | Resume

Subscribe to newsletter




Get Firefox

Monitored by Site24x7
Uptime