6:18 pm

Installing PHP on Windows XP

This tutorial will show you how to install PHP 5.2.8 on machine running Windows XP.

To start with we will download all of the necessary applications which can be found at the following locations:

PHP: PHP download page
File to download: PHP 5.2.8 zip package

Create a folder on your desktop and place all downloaded files inside of it.

Now go the the C:\ drive and create a folder with a name webserver.
This will be the folder where all of our apache, php and mysql files will be kept. Inside of this create another folder: php.

Installing PHP
Go to your desktop and in the folder you initially created find file called php-5.2.8-Win32.zip.
Extract the content of this file to C:\webserver\php. Pull out all of the files from the php-5.2.8-Win32 folder and place them directly in C:\webserver\php.

Now we need to add our C:\webserver\php folder to the path of the Environment Variables.
To do this right click My Computer icon on your desktop and choose Properties. Then choose Advanced tab and click Environment Variables button (Fig. 13).

Installing PHP Step 1
Fig. 13

Now select Path from the System variables list in the bottom part of the window and click Edit (Fig. 14).

Installing PHP Step 2
Fig. 14

In the new window click inside the Variable value: box and press End button on your keyboard to get to the end of the path.
Now type in or copy and paste the following ;C:\webserver\php (Fig. 15). Make sure you start it with semicolon and to use back slashes.

Installing PHP Step 3
Fig. 15

Once you have done this click OK in all of the windows until you close the System Properties window. Now you need to restart the computer.

Next step will be to find out if our PHP is working. Go to Start > Run and type cmd. In the command prompt window type php -v. You should see something like Fig. 16.

Installing PHP Step 4
Fig. 16

We still have some tweaking to do before we finish our installation.
Go to C:\webserver\php and find file called php.ini-recommended. Rename that file to php.ini.
Open this file and make the following amendments:

  1. identify line with doc_root = and change it to:
    doc_root = C:\webserver\Apache2\htdocs
  2. identify line with extension_dir = "./" and change it to:
    extension_dir = C:\webserver\php\ext

Save and close the file.

Apache Configuration
Now we need to make sure that Apache knows where to search for php modules.
To do that first go to C:\webserver\Apache2\conf and open file httpd.conf in your text editor.
Because we will be running PHP as an Apache module which is faster and more secure option comparing to CGI binary, we will need to do the following changes to httpd.conf file:

  1. identify LoadModule section and add the following line at the top of this section:
    LoadModule php5_module "C:/webserver/php/php5apache2.dll"
  2. identify AddType section and add the following line at the top of this section:
    AddType application/x-httpd-php .php
  3. lastly place the following line somewhere within the content:
    PHPIniDir "C:/webserver/php/" - ensure you have a closing slash at the end of the path.

Save and close file. Restart Apache by going to Start > All Programs > Apache HTTP Server 2.0.59 > Control Apache Server and click Restart.

Now go to C:\webserver\Apache2\htdocs folder and select all files by pressing Ctrl + A on your keyboard. Right click on any of the selected files and choose Properties. In Attributes section of the General tab tick Hidden checkbox and click Apply and OK to close the window. This way you will only see your own files in this folder which is the root of our web server and the place where you will be setting up all your projects.

Inside C:\webserver\Apache2\htdocs create a file and give it a name phpinfo.php. Open this file with your text editor and place the following line:
. Save and close the file.

Open your browser and type the following line in the URL:
http://localhost/phpinfo.php.
You should see now a PHP information page (Fig. 17).

Installing PHP Step 5
Fig. 17

Now that our Apache and PHP is installed let´s move on to the next section where we will be installing MySQL.

0 comments: