The Most Advanced Personal Content Management System

Install Apache, MySQL and PHP on Windows

This article aims to provide a full reference for installing and configuring Apache 2 web-server, with mod_rewrite, PHP 4.3.9 scripting language, iconv PHP extension, and MySQL 4 database under Windows. PHP 4 will can be installed / configured as Apache 2 module or CGI script, but installing it as a module is a recommended approach.

First, you will need to download following files:

  • binary form of Apache 2.0.52 (file apache_2.0.52-win32-x86-no_ssl.msi).
  • PHP 4.3.9, I also recommend to download a PHP manual (in .chm file format).
  • MySQL 4.0/4.1, including its manual and documentation.
  • I also recommend to download from mysql.com utility called MySQL Control Center (current version 0.9.3), which is more comfortable to use than phpMyAdmin (which your web-hosting probably provides).

Download binary form of all files from links provided.

This assumes that:

  • Apache 2.0.52 web-server is installed under c:/program files/apache group/apache2.
  • PHP is installed under c:/php/
  • Web is located under c:/www/

When installing Apache, PHP and MySQL, always select a "default installation", no special configuration is needed at this time. After finishing installation, you will have to download configuration file provided, or make manual adjustments to these files:

  • httpd.conf: at c:/program files/apache group/apache2/conf/.
  • php.ini: at c:/php/

Setting-up Apache with mod_rewrite:

(this means modifying file c:/program files/apache group/apache2/conf/httpd.conf)

Setting-up DocumentRoot:

DocumentRoot "C:/www"
ServerName localhost
ServerAdmin your@email.com

Module mod_rewrite:

LoadModule rewrite_module modules/mod_rewrite.so

Allow .htaccess:

<Directory>
 Options FollowSymLinks
 AllowOverride None
</Directory>
<Directory "C:/www">
 Options Indexes Includes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 Allow from all
</Directory>

Dissalow clients to access .htacces:

<Files ~ "^\.ht">
   Order allow,deny
   Deny from all
</Files>

Install PHP as a CGI skript - NOT recommended:

ScriptAlias /php4/ "C:/php/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
Action application/x-httpd-php "/php4/php.exe"

Install PHP as a module - recommended:

LoadModule php4_module "c:/php/sapi/php4apache2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4

Add index.php to Apache search pattern:

DirectoryIndex index.html index.htm index.php

PHP settings

(you need to modify file c:/php/php.ini, assuming PHP installation at C:/php/):

; report all errors
error_reporting  =  E_ALL
display_errors = On
; set to On, if your scripts do not work,
; but your scripts should be able to work in
; Off setting as well; this is more secure
register_globals = Off
; includes and extensions
include_path = ".;c:\php\includes"
extension_dir = "c:\php\extensions\"
; iconv support
extension=php_iconv.dll
; mbstring support
extension=php_mbstring.dll
; smtp
SMTP = smtp.email.com
sendmail_from = your@email.com
[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On
[Session]
session.save_handler = files 
session.save_path = "c:/php/tmp"
session.use_cookies = 1 
session.name = PHPSESSID 

What's left?

Finally, copy

  • all files from c:/php/dlls/ into c:/windows/system32/
  • file c:/php/php4ts.dll into c:/windows/system32/
  • file c:/php/php.ini into c:/windows/system32/ and c:/windows/

Now, you can restart your computer for changes to take effect. Installation and configuration is complete!

Oh, btw, default MySQL username is "root" and password is empty, "". :)

If you are using mod_rewrite and .htaccess and getting "No input file specified." error, add following to PHP.INI file:

cgi.fix_pathinfo=1

Testing

Want to test your installation? Create, under DocumentRoot, file index.php with the following content:

<?php phpinfo(); ?>

This will display 5 pages of info about Apache and PHP configuration.

TOPlist