WAMP - Windows Apache MySQL PHP (LAMP for Win)

The following instructions will assist you with configuring a WAMP server on your Windows desktop.

Apache Web Server
Download the latest version of Apache 2.0 series as a msi install. http://httpd.apache.org

When installing, select the custom install. Accept the default values When at the components page, select the root component and change the default install directory from “c:\program files\apache foundation” to simply “C:\”. This will install apache here:

c:\apache2
c:\apache2\bin\apache.exe
c:\apache2\htdocs
c:\apache2\logs

PHP
Download the latest versions of PHP and PECL packages in zip format found here: http://www.php.net

Unzip the standard PHP package here:

c:\php

Unzip the PECL packages here:

c:\php\ext

Make the following directories:

c:\php\uploadtemp
c:\php\sessions
c:\php\conf

Copy the php.ini-recommended to the following file:

c:\php\php.ini

Edit the php.ini, changing the following settings:

error_reporting = E_ALL & ~E_NOTICE

display_errors = On

extension_dir = “c:/php/ext/”

upload_tmp_dir = c:/php/uploadtemp/

upload_max_filesize = 8M

; Uncomment the following extensions
extension=php_mbstring.dll
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mysql.dll
extension=php_sockets.dll
extension=php_zip.dll

sendmail_from = your@email.com

session.save_path = “C:/php/sessions”

Create the following apache conf file and save it as c:\php\conf\php.conf

LoadModule php5_module “c:/php/php5apache2.dll”
PHPIniDir “C:/php”
AddType application/x-httpd-php .php
DirectoryIndex index.php

Add the following line to your apache conf file (near the bottom of the file, before VirtualHosts):

Include “C:/php/conf/php.conf”

In your c:\apache2\htdocs folder, you may seen many files called ‘index.html.*’. These are safe to delete. Create a new file in your c:\apache2\htdocs folder called phpinfo.php and open in your favorite editor. Add the following code: <?php phpinfo(); ?>

Restart apache. Go to the following URL and verify that PHP is installed correctly

http://localhost/phpinfo.php

Add to the PATH environment variable.

PATH=c:\php;c:\php\ext;…
(where … means the existing values)

You should now reboot your computer for the change in environment variables to take effect. (So modules such as MySQL can be loaded).

MySQL

Install the latest version of the MySQL 5.0.x series in zip format found here: http://www.mysql.com

Extract the files to the following directory:

c:\mysql

Install MySQL as a service by opening the command prompt, and browsing to the following directory:

cd c:\mysql\bin
mysqld-nt –install

MySQL (alternate)
You can also install the latest ‘essential’ version of MySQL as an install: http://www.mysql.com

Change the installation directory to C:\mysql

Make sure to check “Install as a service”

If you enter a root password, you’ll have to enter that in phpMyAdmin’s config.inc.php

phpMyAdmin

Download the latest version of phpMyAdmin, english format in either zip or 7z format found here: http://www.phpmyadmin.net

Unzip the contents of the branch version to the following folder:

C:\apache2\htdocs\phpmyadmin\

Create a new config.inc.php modeled from the sample config file in the current directory. Don’t forget to include the <?php and ?> at the beginning and end of the file.

c:\apache2\phpmyadmin\config.inc.php

Edit in your favorite editor. Make sure to add the following settings:

$cfg['blowfish_secret'] = ‘random-str’;
$i = 0;
$i++;
$cfg['Servers'][$i]['auth_type'] = ‘config’;
$cfg['Servers'][$i]['user'] = ‘root’;
$cfg['Servers'][$i]['password'] = ”; // put here your password after
// setting one ( strongly recommended ! )
$cfg['Servers'][$i]['ssl'] = false; // pma 2.10.0.0

Go into the phpmyadmin, create a pma user. Follow the instructions found here: http://wiki.cihar.com/pma/controluser

Edit the config.inc.php file in your favorite editor a second time.

$cfg['blowfish_secret'] = ‘random-str’;
$i = 0;
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = ‘cookie’;
/* Server parameters */
$cfg['Servers'][$i]['host'] = ‘localhost’;
$cfg['Servers'][$i]['connect_type'] = ‘tcp’;
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = ‘mysql’;
/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = ‘pma’;
$cfg['Servers'][$i]['controlpass'] = ‘pma’;
// For your sanity, set the cookie to not expire for 12 hours.
$cfg['LoginCookieValidity'] = (60*60*12);

Last, change your root password so it is secure. You should now be able to sign in/out of phpmyadmin with the root password.

Create Apache Config Files for Each Site
Similar to the config file created for loading php in apache, we will create separate config files for each local web site you wish to host on your computer.

Create a folder on your computer where you would like your local web site to reside. Example:

c:\projects\my_website

Create a cgi-bin, conf, htdocs and logs folders within the my_website folder. Example:

c:\projects\my_website\cgi-bin
c:\projects\my_website\conf
c:\projects\my_website\htdocs
c:\projects\my_website\logs

Create an apache configuration file for your web site:

c:\my_website\conf\httpd.conf

Open the httpd.conf file in your favorite editor and add the following:

# my_website.com
<VirtualHost *:80>

# General site settings
ServerName www.my_website.local
ServerAlias my_website.local
ServerAdmin postmaster@my_website.com

# PHP Settings (optional):
php_flag display_errors on
php_value error_reporting 2039

# htdocs:
DocumentRoot “c:/projects/my_website/htdocs”
<Directory “c:/projects/my_website/htdocs”>
Allow from all
AllowOverride Options FileInfo AuthConfig
Options Includes FollowSymLinks
</Directory>

# cgi-bin (optional):
ScriptAlias “/cgi-bin/” “c:/projects/my_website/cgi-bin”
<Directory “c:/projects/my_website/cgi-bin”>
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

# Support phpMyAdmin (optional):
Alias “/phpmyadmin/” “c:/apache2/htdocs/phpmyadmin”

# Logging
ErrorLog “c:/projects/my_website/logs/error.log”
CustomLog “c:/projects/my_website/logs/access.log” combined
</VirtualHost>

You may switch the use of .local with .com if you like. I prefer to use .local so I know I am working with a local copy of my web site and not the actual production web site.

Open the main apache httpd.conf file (c:\apache2\conf\httpd.conf) and include the following at the very bottom of the configuration file:

# Enable virtual hosts in Apache:
NameVirtualHost *:80

# Default htdocs directory for all unknown virtual hosts:
<VirtualHost *:80>
DocumentRoot c:/apache2/htdocs
ServerName localhost
</VirtualHost>

# Include your own apache configuration files
Include “C:\projects\my_website\conf\httpd.conf”

Add the following line to your windows hosts file (c:\windows\system32\drivers\etc\hosts):

127.0.0.1 my_website.local www.my_website.local

Restart apache, then browse to the following url in your web browser.

http://my_website.local

Conclusion
Hopefully you will find these steps useful for configuring your own WAMP server on your desktop. The steps above were carefully crafted so you can quickly upgrade any of the software without having to perform a lot of re-configuration. I hope you find this method of installing and configuring Apache, MySQL and PHP on a Windows desktop as useful I do.

Blubrry player!