Install Web Server in Windows XP with Apache2 and PHP5

Aug 16, 2007 15:32 GMT  ·  By

The easiest way to install PHP and Apache is to use software bundles like XAMPP, WAMP, Apache2Triad and many others. But many web developers prefer to install everything manually.

So, the first step is to download the latest versions of the packages, for security reasons: PHP 5.2.3 and Apache 2.2.4.

Installing Apache is easier if you download .msi package. Run the installation wizard and in the Server information window insert localhost at Network Domain and Server Name. In the same window, choose if you want to install Apache as a Service or if you want to start it manually. In the next windows choose typical installation, then choose the folder where you want to install Apache and so the installation is completed. By default, Apache's document root is set to htdocs directory. htdocs is located in C:/Program Files/Apache Software Foundation/Apache2.2/htdocs.

To install PHP, first you have to extract the PHP package to c:php. Rename php.ini-dist to php.ini and copy the file to windows folder: C:/Windows. PHP stores in php.ini all the configurations and if you want to install, for example, an extension, you will need to modify this file. Edit php.ini in WordPad and go to the 'Paths and Directories' section. Replace doc_root= withdoc_root = "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"

Now you have to configure Apache to work with PHP. Open httpd.conf file from "C:/Program Files/Apache Software Foundation/Apache2.2/conf". There you have to add:

code
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
and also configure the path to php.ini and add this line:
code
PHPIniDir "C:/php/"
Save and close the file and restart Apache. To test the installation, paste the following code [CODE=0][CODE=1]

to wordpad, rename it to phpinfo.php and copy it to htdocs folder. In your browser type: http://localhost/phpinfo.php and you should have a screen with Server related information and variables.