Installing Apache and PHP under windows

Posted under » PHP » Apache on 5 January 2011

The trick about making it work in Windows is knowing what to download. Knowing what to edit comes next.

Installing Apache by MSI is a good idea because over the years, Apache has greatly improved its automated installation.

PHP installers sux. Do not download it, instead download the Zip version. If you don't have the missing files, you can download it later right? Wrong. This is dangerous because it could be a virus or in most likely scenario, the wrong version of the file and it will not work. You don't have to pull your hair trying to compile it from source. Just download, unzip to a folder like c:\php\

In order to enable PHP to run with Apache (on Windows), you have to edit the Apache config. You might find it here.
C:\Apache2.2\conf\httpd.conf Now add this

LoadModule php5_module "c:/php/php5apache2_2.dll"

AddType application/x-httpd-php .php

DirectoryIndex index.php index.html index.htm

PHPIniDir "c:/PHP"

For more details ... read here. VC9 x86 Thread Safe zip contains the dll. Non Thread Safe has no apache dll.

Some modules that I often use

LoadModule rewrite_module modules/
LoadModule vhost_alias_module modules/

Other configs

DocumentRoot D:/webroot
<Directory D:\webroot >
<Directory E:\webroot\drupal >
    AllowOverride All
# Virtual hosts only applies to windows
Include conf/extra/httpd-vhosts.conf

A virtual host typically look like this. It is important to define your directory config. Otherwise you might get a "permission error".

<VirtualHost *:80>
	ServerAdmin webmaster@localhost
    DocumentRoot "E:\www\sample"

	<Directory E:\www\sample\>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all

	ErrorLog E:\Apache2.2\logs\error-sample.log
	LogLevel warn
	CustomLog E:\Apache2.2\logs\access-sample.log combined

As for MySQL. Installing the community server via msi is straight forward. While at it, you may want to install the MySQL workbench tool. It's like phpmyAdmin on steroids.

Next step is to fine tune your PHP installation by modifying the php.ini or your my.cnf.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS