Installation and Configuration

You have Windows XP or Vista. Download the other packages from their respectives sites:

  1. Apache from httpd.apache.org
  2. MySQL from http://www.mysql.com
  3. PHP from http://www.php.net

Download the latest stable versions. In this section, we are using Apache 2.0.55, MySQL 5.0.18 and PHP 5.1.5.

After installing Apache, you may see the files in the folder C:\Program Files\Apache Group\Apache2\. The web pages are stored in “htdocs” sub-folder and the configuration files are stored in “conf” sub-folder. You may save your web pages in a new folder “c:\htdocs”. In this case you need to modify the “httpd” file in “conf” folder to make these changes:

DocumentRoot “C:/htdocs”

<Directory “C:/htdocs”>

Open a browser and type

http://localhost

If the Apache is installed properly, you will see a screen as shown below:

There are two main ways to install PHP for Windows: either manually or by using the installer. Once you have PHP installed on your Windows system, you may also want to load various extensions for added functionality.

Try the PHP 5.1.5 installer downloaded. It will install PHP into C:\PHP. You may see a screen to choose the Server Type from a number of options, which include web servers like PWS, IIS, Apache and Xitami.

php11.jpg

Unfortunately, I was asked to configure the web server manually, when opted for Apache. Let us do that!

Unzip the downloaded PHP 5.1.5 zip file into the C:\PHP folder. Open the file “php.ini-recommended” and save it as “php.ini” to your Windows folder (e.g., C:\Windows). Copy “php5ts.dll” to any path mentioned in PATH environment variable (e.g., C:\Windows\System32).

At his point of time, Apache does not recognize PHP pages. If you load the test page now in your browser, you will get a screen similar to the following, since Apache does not get the help of PHP to interpret the page:

 test2.jpg

Now modify Apache configuration file httpd to reflect the following lines:

 LoadModule php5_module “c:/php/php5apache2.dll”

AddType application/x-httpd-php .php

Restart Apache web server. Test the page “test.php” with your browser. If the installations are correct, you may get a screen similar to the following:

php3.jpg 

Scroll down the page. There is much information available on the PHP setup on Apache. Note that we have now a database engine called “sqlite” as part of the PHP.

Next install the full fledged database MySQL 5.0.18. The installation will complete the service configuration as well, so that Windows will start MySQL as a service. Once the installation is over, you may try the command line client. It will appear as shown below:

 mysql.jpg

Again, configure PHP to talk to MySQL. Open php.ini (in C:\WINDOWS) and make the following modifications:

1. Find “extension_dir” and modify it to show the directory in which the loadable extensions (modules) reside.

extension_dir = “c:\php\ext”

2. Locate Windows extensions and uncomment the line which reads:

                        Extension = php_mysql.dll

3. In order to use PHP’s session functions, you need to modify session save path as shown here:

session.save_path = “c:\windows\temp”

Finally, add C:\PHP as a path in Windows system environment variable PATH. Otherwise, while Apache tries to load php-mysql.dll, it may show an error warning like this:

“PHP Startup: Unable to load dynamic library ‘php_mysql.dll’ –

The specified module could not be found.”

If everything is done right, if you again test the page “test.php” in your browser, you will see screens with MySQL variables defined as shown below:

mysql2.jpg

mysql3.jpg

Advertisements

One thought on “Installation and Configuration

  1. Bill

    Thanks! I used your site to realize that I did not load the php module.

    For some reason tho, the default pages come up with the “open with” prompt when I use a directory url instead of a direct link

    ie location/index.php works, but not location/

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s