Installing PHP and Apache have been done quite frequently by all I think and most of them know about it. But I believe some others might want to up to date installing VC9 PHP and Apache in windows system.

So I thought that I share this and there is not that right place than sitepoint PHP forum.

Requirement
To run the applications compiled with VC8 or VC10, it is required to install the respective (or latest one is always better) Visual C++ redistributable packages. You can download the package from Microsoft's official site for free.
  1. To download Visual C++ 2008 - http://www.microsoft.com/download/en...s.aspx?id=5582
  2. To download Visual C++ 2010 - http://www.microsoft.com/download/en...s.aspx?id=8328

Note: If you have any Visual Studio installed in your PC then you don't have to install them separately.

Where to install?
Since I have not used any installers for both PHP and Apache, I will be downloading the pre compiled zipped packages and install them in my D drive. The folder structure will look like below:
  1. d:/etc/apache - Apache installation
  2. d:/etc/php - PHP installation
  3. d:/etc/www - document root folder

Note: You can change the drive and path for the installations in your own way.

Download
  1. Download the latest Apache 2.4.1 (as of writing this) from http://www.apachelounge.com/download/ (direct link for the current version - http://www.apachelounge.com/download....4.1-win32.zip) and unzip it in d:/etc/apache
  2. Download latest version 5.4 from http://windows.php.net/download and unzip it in d:/etc/php. While downloading PHP, choose the Thread Safe version for windows.
  3. Download the PHP and Apache connector DLL file from http://www.apachelounge.com/download/ (direct link: http://www.apachelounge.com/download...-5.4-win32.zip) and extract the file php5apache2_4.dll and copy it to d:/etc/php.


Configurations
Though the configurations may vary from individual's requirement but here I will be discussing for some basic configurations in PHP and Apache.

Apache
  1. Open the file d:/etc/apache/conf/httpd.conf in any text editor (I use my lovely Notepad++) then find and make the following changes/configurations as per your installation path.
  2. Set the server root
    Code PHP:
    ServerRoot "D:/etc/apache"
  3. Enable required Apache modules. I just uncomment one more for mod_rewrite module.
  4. Add the following lines somewhere (I did just below the module enabling)
    Code PHP:
    LoadModule php5_module "d:/etc/php/php5apache2_4.dll"
    AddHandler application/x-httpd-php .php
    PHPIniDir "d:/etc/php"
  5. Change server admin email address
    Code PHP:
    ServerAdmin [email]info@yoursite.com[/email]
  6. Change the document root:
    Code PHP:
    DocumentRoot "d:/etc/www"
    <Directory "d:/etc/www">
  7. If you want to allow .htaccess to be used under document root do the following under <Directory "d:/etc/www">
    Code PHP:
    AllowOverride All
  8. Find the follwoing and replace the path:
    Code PHP:
    ScriptAlias /cgi-bin/ "d:/etc/apache/cgi-bin/"
    <Directory "d:/etc/apache/cgi-bin">
  9. Add index.php in directory index
    Code PHP:
    DirectoryIndex index.html [B][I]index.php[/I][/B]


PHP
  1. Rename php.ini-development to php.ini
  2. Find extension directory setting and set the path as per your installation.
    Code PHP:
    extension_dir = "d:\etc\php\ext"
  3. Uncomment (remove the simicolon ; from the beginning of the line) the extensions that you want to enable them. i.e.
    Code PHP:
    extension=php_curl.dll
    extension=php_mysql.dll
    extension=php_mysqli.dll
    extension=php_pdo_mysql.dll
    extension=php_soap.dll
  4. If you want to test email sending from the PHP in local system, then you need to set the SMTP. i.e.
    Code PHP:
    SMTP = smtp.yoursite.com
    smtp_port = 25
    sendmail_from = [email]youremail@sender.com[/email]

Rest of the changes/configurations are totally depends on requirement project wise.

Set Environment Variables for PHP (Windows 7)
  1. To be available PHP globally in Windows, the path of the PHP has to be set.
  2. Right click on Computer and click Properties.
  3. Click on Advanced system settings on the left side (top).
  4. Click on the Environment variables.
  5. Under System variables, double click the Path variable name and add ;d:\etc\php without double quotes at the end where semicolon ( ; ) is the separator.
  6. Click OK to save. Sometimes you may need to restart the computer this to take it into effect.


Install Apache as Service
Since we have just copied the files in a folder, the Apache is not yet not a windows service. To install it as a service follow the steps.
  1. Run the command line (cmd.exe) As Administrator. Browse the folder c:\Windows\System32\ and right click on cmd.exe and select Run as Administrator.
  2. Change directory to d:\etc\apache\bin in the command line
    Code PHP:
    cd d:\etc\apache\bin
  3. Run the command to install it
    Code PHP:
    httpd -k install #(or sometimes httpd.exe -k install if that does not work)


Now restart the computer and test both PHP and Apache. To test both together create a PHP file phpinfo.php in d:\etc\www. Now browse in the browser as http://localhost/phpinfo.php.

If you can see the PHP information then now you are done !

I am sorry if there are any language issues (due to weak English correct words, grammar mistakes) but I believe that it is understandable. I had also posted it in my blog. Also please suggest if I have made any mistakes or written something wrong, I would be grateful to you.