RIPr

Apache 2.2 and PHP 5.2.6 on Vista

Posted in Tech by ripr on February 11, 2010

Recently, I decided to learn web programming and started off with with PHP and MySQL. For reference,  I bought buying the PHP and MySQL Web Development book by Luke Welling and Laura Wellington.

I have Windows Vista on a Lenovo Thinkpad SL500.

For Apache, I used apache_2.2.14-win32-x86-openssl-0.9.8k installer and it was very easy to install. Once I got the ‘It works!‘ page, that bit was complete.

Next came PHP which was the tricky bit. Considering I have no experience with PHP, I chose to use php-5.2.12-win32-installer installer. Installer asked for Apache’s conf directory at one point and rest was straightforward.

However, after doing all this, I still couldn’t get it working and after two evenings of research on the internet, I got it working by doing the following:

httpd.conf changes

1. Set the PHP5 Module

Search for LoadModule in httpd.conf and then add an entry for php5_module as follows:

LoadModule php5_module “C:/Program Files/php/php5apache2_2.dll”

2. Change the DocumentRoot.

Search for ‘DocumentRoot‘ in httpd.conf and set it as follows:

DocumentRoot “D:/website

assuming D:/website is the place where you want to keep your webpages.

3. Change the Directory

Search for <Directory> in httpd.conf and set it to the same path as DocumentRoot. In my case, it looked like this:

<Directory “D:/website”>

4. Add the php5 type

Search for <IfModule mime_module> in httpd.conf . Inside this, you’ll find lot of different types of entries. Some start with AddType. Add a similar entry for PHP before the closing </IfModule>tag as follows:

AddType application/x-httpd-php .php

5. Set the PHPIniDir

In the end of the httpd.conf file, add an entry for PHPIniDir. This should be the same as your PHP installation path. In my case, it looked as follows:

PHPIniDir “C:/Program Files/php”

The next stage was to configure PHP.

php.ini changes

Here are the steps:

1. Set the doc_root

At the moment, I’m keeping my HTML and PHP pages in the same location. If you want the same then look for doc_root in the php.ini file and update it as follows:

doc_root = “D:\website”

2. Set the php extensions

Look for extension_dir in php.ini file. If your installation path is “C:/Program Files/php” then set extension_dir as follows:

extension_dir=”C:/Program Files/php/ext”

Test configuration

After this, restart your Apache service and test your configuration by setting opening “http://localhost/phpinfo.php” . If you get a page that tells about various settings in PHP, then you are ready to go.

Goodluck !

Tagged with: , ,

Leave a comment