Copy the PHP files that you downloaded to "D:\Server\PHP\". We have to add this directory to our startup path so that Windows can access the directory whenever any references are made to PHP. Right click on My Computer. Click on Properties. Select Advanced. Click on Environment Variables. From the System Variables Group, select Path and click on edit. Append at the end of the Variable Value field, ";D:\Server\PHP"(without the quotes). Restart your computer. When Windows come back, to verify whether your computer has access to PHP, fire up the Run prompt. Type in
cmd
. In the command prompt, type in php -v
. If everything is right, you will get information about the PHP version that you have downloaded and installed.Navigate to the PHP directory and find the file named
php.ini-recommended
. Rename the file to php.ini
. Open up the file in any text editor of your choice. Search for a phrase called doc_root
. This is the root directory of our website. since we've decided it to be "D:\Server\", set the doc_root property to that value. Nearby, you can also configure the PHP extension directory. Set its path to a directory of your choice.Thats all to be done for PHP.
Now, on to configuring Apache.
Let us say that you installed Apache in "D:\Server\Apache\". Navigate to that location(and open up the httpd.conf file in any text editor of your choice(or select start»Apache HTTP Server»Configure Apache Server»Edit the httpd.conf file). I use Notepad++ If you find it utterly irritating to type in
:8080
with every address that you enter, search around for a phrase Listen 8080
and change that line to Listen 80
. Port 80 is the default http port. Restart the Apache Server and verify that if we type in http://localhost
in our browser, we will get the Apache page.We are going to load PHP as an Apache module. PHP can be used as a CGI or as an Apache module. For the time being, lets load PHP as an Apache module. It is usually good practice to load PHP in this manner as it makes your code more secure. Note that you cannot run PHP as a module and a CGI at the same time.
Now, search for a phrase LoadModule in the httpd.conf file. To the list of modules already addded, add the following code :
LoadModule php5_module "D:/Server/PHP/php5apache2.dll"
Now, search for "AddType" section and add the following code:
AddType application/x-httpd-php .php
You can add other extensions as well if you want PHP to parse them.
Finally, add the following line somewhere in the file that seems nice to you :
PHPIniDir "D:/Server/PHP/"
Actually you can add the lines anywhere in the file. I just mentioned you add them in sensible places.
Now for the final check, open up any text editor. Type in the following code :
<?php phpinfo(); ?>
Save the file as phpinfo.php in "D:\Server\". Open up a browser after starting Apache and type in "localhost\phpinfo.php" If all goes well, you would see a screen similar to the one below
