Install-a-WAMP(P)(P)
v2.6 r21jul2013 fr27feb2002
by Elf Qrin




Let's say you are a Windows user willing to install a webserver on your system. What you need is a WAMP. WAMP stands for Windows, Apache, MySQL, PHP. Such system will allow you to serve documents on the Internet, allowing server side scripting with PHP and database management with MySQL. And the best part is that everything (besides Windows) is free. If you want you may include Perl too, so now we can call this system WAMPP.
This tutorial will show you how to set up such system in easy steps.

Important: this guide will not teach you how to configure each software and fine tune it, but only how to install them properly and make them work together.

I've updated this document for Apache v2.0.x, since now the Apache group is recommending it over v1.3.x for it's much more fast and secure, especially on Windows systems. Note that Apache v2.x requires updated versions of PHP, MySQL, and Perl, since the ones that were working with your old installation of Apache v1.3.x may not work with the latest release of Apache. In particular, you need at least PHP v4.1.2 to work with Apache 2.



WINDOWS

This document supposes you have Windows already installed... in case you need to update parts of your operating system (especially security related patches), you can use Windows Update at http://windowsupdate.microsoft.com/ (requires Internet Explorer 6: http://www.microsoft.com/windows/ie/default.asp )



APACHE Webserver

home page: http://www.apache.org/

download page: http://httpd.apache.org/download.cgi


Get the latest stable (non beta) release. The file name should be something link httpd-x.x.xx-win32-x86-no_ssl.msi (or httpd-x.x.xx-win32-x86-openssl-x.x.xx.msi if you need SSL support) where x.x.xx is the version number, win32 the operating system, x86 the CPU.

Alternatively, you can go to the download mirrors area ( http://www.apache.org/mirrors/ ) and choose the mirror nearest to you. There's no direct download. You'll have to browse through directories, try something like httpd/binaries/win32/ and download the file called something like httpd-x.x.xx-win32-x86-no_ssl.msi (or httpd-x.x.xx-win32-x86-openssl-x.x.xx.msi if you need SSL support).

Double click on the program to install it. During the installation you'll have to enter the Network Domain (e.g. example.net), the Server Name (e.g. www.example.net), and the Administrator's e-mail address (e.g. webmaster@example.net). Such data are not vital, but they will be shown on the user's browser when an error occour. You can also modify them later, editing the Apache configuration file.

Then you'll have to choose if you want to Run Apache as a service for all users (i.e. if it should start with Windows) or you want to start it manually double clicking on its icon. By default, the installer sets Apache installed as a service to listen to port 80, and Apache installed to start manually to listen to port 8080. You'd probably better install it as a service anyway, and if you want it to be started manually, set the service to start manually (to do so, once Apache is installed, right click on the Apache monitor's icon on the task bar, click on Open Services, right click on the entry Apachex.x, choose Properties, and set start to Manual).

You can choose the default installation.

The default destination directory is C:\Program Files\Apache Software Foundation\Apachex.x and you can leave it unchanged.

Once you've finished, Apache is ready to start, you don't need to reboot Windows.

To configure Apache you have to modify the httpd.conf file in the conf directory.

The first thing to do is to define the Document Root directory. All the documents inside that directory will be accessible through Apache.

Locate the DocumentRoot statement (by default something like DocumentRoot "C:/Program Files/Apache Software Foundation/Apachex.x/htdocs") and redefine it as DocumentRoot "C:/internet/htdocs" or whatever you like. Then place the websites you want to make available through Apache inside this directory. Note that defining DocumentRoot is not enough. There could be further occurrences of the text string "C:/Program Files/Apache Software Foundation/Apachex.x/htdocs" (or wherever you've installed Apache) so that you'll have to fix them manually according to your new DocumentRoot directory.

You have to define the port to which Apache will listen. The default HTTP port is 80, but Apache 2 sets it as 8080 if you chose to start the server manually, because it assumes it's a secondary webserver while the primary is launched automatically when the operating system starts. You can change this behavior by modifying the following line:

Listen 80

You can make the webserver listen to more than one port, in case you need it.
On Apache v1.3.x instead you must use the Port directive (example: Port 80 ) to choose the primary port, and Listen to choose additional ports the webserver will listen to.

If Apache won't start when Skype is running, it's because there's a conflict with port 80 that Skype can optionally use to bypass some network restrictions. To fix it, open Skype and go to Tools / Options... / Advanced / Connection and uncheck Use port 80 and 443 as alternatives for incoming connections, then Save the new configuration, and restart Skype

You may want to enable SSI (Server Side Includes), which will make Apache process .shtml documents.

Add these lines anywhere in the configuration file for Apache v1.3.x:

#ssi

Options +Includes
AddType text/html .shtml
AddHandler server-parsed .shtml


or these lines for Apache v2.x:

#ssi

Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml


You can enable .htaccess files to set access rules for every directory inserting the AllowOverride All directive within the <Directory "YOUR_ROOT_DIRECTORY"> </Directory> tag pairs.

There could be some problems installing Apache on Windows 2000 Server because Apache and MicroSoft IIS webservers can "fight" for port 80. So you can either assign a different port (like 8080) to Apache using the Listen directive or disable IIS (which is way better... there's probably no need of IIS if you have Apache). If you use a different port of course users will have to access to your system like this http://your_computers_IP:8080/, but if you are behind a router you can redirect incoming connections to port 80 to port 8080 (which would make the "real" port 80 that could be owned by IIS unavailable).

Further editing of httpd.conf is required after installing PHP and Perl.



PHP

home page: http://www.php.net/

download page: http://windows.php.net/download/


Go to the downloads area and get the lastest Zip package (NOT the Installer) from the Windows Binaries section. It is recommended to use the Thread Safe version of PHP with Apache. The Zip package includes server API versions for Apache, AOLserver, ISAPI and NSAPI. MySQL support built-in, and many extensions.

You may also download Security fixes and Patches for the latest version if available.

Extract the zipped archive to C:\Program Files\PHP Apply fixes/patches if you downloaded them.

Create a PHP configuration file making a copy of php.ini-development or better php.ini-production and renaming it as php.ini ( -development is more verbose than -production when returning errors but may leak otherwise secure information; in the past, PHP used to be installed with two sample ini files: php.ini-dist was more tolerant and worked with most script, while php.ini-recommended was more strict and secure, but could cause some scripts to don't work properly). You don't need to modify it to make PHP work with Apache at this stage, but you'd better open and customize it anyway. However you'll have to edit it later to make PHP work with other applications.
Make sure that engine = On is set, otherwise PHP will not work at all.
One thing you may want to set is short_open_tag = On to allow <? ?> tags in your PHP scripts besides the more verbose <?php ?>
You'll need to set extension_dir = "ext" to load extensions.

Open the Apache configuration file (httpd.conf) and add these lines:

#php

<Directory "C:/Program Files/PHP">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>


ScriptAlias /php/ "C:/Program Files/PHP/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"


Note that Directory and ScriptAlias must contain the actual path to PHP, so that the above lines are correct if you have extracted it to C:\Program Files\PHP , otherwise you'll get this error message when you try to open a PHP page on your localhost: "You don't have permission to access /php/php-cgi.exe/".

Also add index.php to the DirectoryIndex directive in the Apache configuration file.

If Apache is running, you'll have to restart it to make changes to the conf file work.

If your script doesn't use environment variables as recommended by PHP (example: $_COOKIE["debug"] , instead of simply referring at it as $debug ), you should set these directives in php.ini, although they are deprecated, especially if you have problems when setting cookies:

error_reporting = E_ALL & ~E_NOTICE
variables_order = "EGPCS"
register_globals = On


If you experience further problems with cookies using old versions of Internet Explorer, try this: go to Tools:Internet options:Privacy:Advance and check the automatic cookies override box and then allow session cookies.

Further editing of php.ini is required after installing MySQL, PostgreSQL, and the SMTP server.



MySQL

home page: http://www.mysql.com/

download page: http://www.mysql.com/downloads/


From the download page get the latest release of MySQL Community Server (which is the free version of MySQL Server) for Microsoft Windows (x86, 32-bit), MSI Installer.

Start the Installer, and accept the license. It's recommended to install all components. The default installation directory is C:\mysql , you may want to change it to C:\Program Files\mysql Choose Detailed Configuration, for the first time. Choose Developer, Server, Dedicated MySQL Server according to your needs (if you are installing it in your own PC, you'll probably need a Developer configuration), then you'll have to choose between Multifunctional, Transactional only, and Non-Transactional only Database (you'd better choose Multifunctional Database). You can choose the default value for most settings. Things you may want to set are the port number (but you'd better leave the default value of 3306), and if the service has to be started manually. Then you'll have to set the password for the root user. If you are installing MySQL in your PC you'll probably want to NOT Enable root access from remote machines.

You may also edit the MySQL configuration file my.ini manually (in the past there used to be two configuration files: my.cnf and my.ini ).

Things you could edit manually:

In the [client] and [mysqld] sections you can set the port number:
port=3306

In [mysqld] section you have to set basedir and datadir according to MySQL installation directory. For example:
basedir="C:/Program Files/MySQL/MySQL Server x.x/"
datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/"

If you haven't set the password using the wizard during the installation, you can specify it in the [client] section: password=PASSWORD_HERE


Once you've configured MySQL, you'll also have to open the PHP configuration file (php.ini), enable the MySQL extension adding (or uncommenting) this line:
extension=php_mysql.dll
and then add these lines:

[MySQL]
mysql.default_port=3306
mysql.default_host=localhost
mysql.default_user=root


Actually the values above should reflect the ones about port, user, and root defined in MySQL my.cnf configuration file.



phpMyAdmin

home page: http://www.phpmyadmin.net/

download page: http://www.phpmyadmin.net/


Download the .zip file for PHP (not the one for PHP3), then extract the ZIP file in a subdirectory inside your Apache DocumentRoot directory.

Open the file config.inc.php in your favourite editor and change the values for host, port, and authentication mode (normally they should be set as host='localhost' , port='3306' or you can leave it blank as 3306 is the default MySQL port, and auth_type='config'), and then set user and password according to the one you've set in MySQL's my.ini configuration file (normally user should be 'root').
If you want to get a login screen where you're asked for username and password for better security, you have to set auth_type='cookie' and leave user and password blank.
You should insert the correct value for $cfgPmaAbsoluteUri with the HTTP path to your phpMyAdmin directory, although in most cases phpMyAdmin is able to autodetect it.
Have a look at Configuration section in Documentation.txt or Documentation.html for an explanation of all values.

To work properly phpMyAdmin requires the extension mbstring for PHP to be enabled; edit php.ini and add (or uncomment) this line:
extension=php_mbstring.dll

Start index.php to administrate your MySQL databases.



PostgreSQL

home page: http://www.postgresql.org/

download page: http://www.postgresql.org/download/windows


From the Windows download page download the One click installer.

Configure PostgreSQL using the wizard during the installation. You may leave default values for most settings:

Set Installation Directory: by default C:\Program Files\PostgreSQL\x.x Set Data Directory: by default C:\Program Files\PostgreSQL\x.x\data

Set the password for database superuser (postgres) and service account (postgres)

Set the port, you can leave the default 5432 port. You may also leave the default locale.

Edit php.ini and add (or uncomment) this line:
extension=php_pgsql.dll



phpPgAdmin

home page: http://phppgadmin.sourceforge.net/doku.php?id=start

download page: http://phppgadmin.sourceforge.net/doku.php?id=download


Download the .zip file, then extract it in a subdirectory inside your Apache DocumentRoot directory.

Open the file phpPgAdmin\conf\config.inc.php in your favourite editor and change the values for host and port: port normally can be left as the default value, and set host as "localhost": $conf['servers'][0]['host'] = 'localhost';
Have a look to the INSTALL text file of phpPgAdmin for further information.

Start index.php to administrate your PostgreSQL databases.



Perl (ActivePerl)

home page: http://www.activestate.com/activeperl

download page: http://www.activestate.com/activeperl/downloads


You may want or need to execute CGI/Perl scripts on your system. In this case you'll have to install and configure a Perl interpreter as well, otherwise if your web site is PHP/MySQL based only, you will not need Perl.

Download the ActivePerl Community Edition, which is the free version.

When you install Perl on your Windows system, if you want to maintain a certain portability with Unix/Linux systems, you should install it in C:\usr instead of the default C:\Perl or C:\Program Files\Perl . In fact, in Perl, you can't declare the path to the Perl interpreter in the webserver's configuration file, as you do with PHP, but you have to specify it in every script, so that you install Perl in C:\Program Files\perl, every Perl script running on your server must begin with #!/Program Files/Perl/bin/perl instead of the Unix/Linux standard #!/usr/bin/perl . Actually Apache for Windows has a workaround for this using Registry file types as we'll see later, but it's probably not recommended.

If you allow setup to add the path statement to your AUTOEXEC.BAT or add the path manually adding this line SET PATH=%PATH%;C:\usr\bin (where C:\usr\bin should be the actual location of PERL.EXE), you'll be able to run Perl scripts from the MS-DOS command line from any directory, like in this example: PERL HELLOWORLD.PL

Once you've installed Perl, you have to enable CGI scripts and Perl in Apache, so you have to edit Apache configuration file (httpd.conf) and add Options +ExecCGI , like this:

#cgi

Options +ExecCGI


Then you'll have to decide if CGI/Perl scripts can run in a specific directory only (old-style), or in any directory served by Apache.

Single directory. Note that this option is enabled by default (besides the fact CGIs are not enabled, i.e. there's no option ExecCGI by default), so that you will find these lines already coded in the configuration file, although I've put them all together here for semplicity:

#cgi

Options +ExecCGI
ScriptAlias /cgi-bin/ "C:/Programmi/Apache Group/Apache/cgi-bin/"
<Directory "C:/Programmi/Apache Group/Apache/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>


If you want to execute CGI scripts in any directory, not just Apache's default CGI directory cgi-bin, you'll have to use these lines instead (and comment out the above lines coded by default):

#cgi

Options +ExecCGI
AddHandler cgi-script .cgi
AddHandler cgi-script .pl


Moreover, Apache for Windows can use file type associations from the Windows Registry, so that if .cgi and .pl are associated with PERL.EXE, you can use the following lines to override the #! directive at the beginning of every Perl script, and to execute CGI scripts from every directory:

#cgi

Options +ExecCGI
ScriptInterpreterSource registry




FTP server (GuildFTPd)

home page: http://www.guildftpd.com/

download page: http://www.guildftpd.com/ (Direct Download link)


This is not actually part of the "WAMPP" system, but in case you need a good and free (although a donation is appreciated) FTP server for Windows, this is the one you should get.

Installation and configuration are very simple, since it's GUI driven. Install it in C:\Program Files\GuildFTPd then start it. You can create single users within groups of users that share part or all the privileges set for that group. Among other settings, the most important one is that you have to set the available paths for every user (or group, so that it will be available for all the users within). The only fundamental thing is that you have to create a virtual root ( / ) directory for all users, so that you can create it at System level to make sure all groups and users have the virtual root directory set. You could phisically set such virtual root directory as C:\ftp for example, then you can create subdirectories inside C:\ftp like pub (read only) and incoming (read/write) and give different access privileges to every user.



SMTP server (PostCast server)

home page: http://www.postcastserver.com/

download page: http://www.postcastserver.com/download/


Download the latest version of PostCast Server Free Edition and install it following instructions.

The application is free, but the first time you start it you'll be asked for your name and e-mail that the authors use to know who is using it. You must provide a valid e-mail.

You can configure the SMTP server choosing "Settings..." from the "Tools" menu, or pressing the "Settings" button in the toolbar. You'll probably want to set "Mail sending frequency" to Immediately in the System tab, so that e-mails you send will be forwarded immediately to the recipient(s). In the Security tab you can restrict access to certain IPs/domains only to avoid spam relay. In the Advanced tag you can set the reply to the HELO handshaking command with the welcome message you want.

To send your mail through the SMTP server, you'll have to set "localhost" as SMTP server in your e-mail applications. If this doesn't work (it's the case of the PHP, for example), you have to use the host name as shown in Settings...:System:Host Name (note that the host name is case sensitive).

If you want to use your SMTP server to send online form from PHP script, you have to set these directives in the PHP configuration file (php.ini):

SMTP = host name as shown in Settings...:System:Host Name (note that the host name is case sensitive)
smtp_port = 25 ; if this value is not set, it will be set to 25 by default


You can override these settings in your PHP scripts using the ini_set statement:

ini_set("SMTP","HOST_NAME"); ini_set("smtp_port",PORT_NUMBER);



GETTING STARTED

Launch WinMySQLadmin and Apache console and your webserver is ready to run and to process PHP scripts and MySQL databases. If there are problems with the webserver check Apache's Error and Access logs. Note that MySQL's traffic light icon must be green, otherwise it means there's a problem and the database is not running. See Start Check and Err File content from MySQL GUI and try to figure out what's going wrong.

To start the FTP server as well, launch GuildFTPd. Check its log if you experience problems.

To access a webpage on your server from a web browser:

From your local system:

http://localhost/
or the equivalent IP
http://127.0.0.1/


From a remote computer on the Internet:

http://your_computers_IP

To know your IP you can type IPCONFIG from an MS-DOS shell window or launch WINIPCFG either from an MS-DOS window or from START menu/Execute...



SHUT DOWN SERVERS

MySQL:
Close MySQL window, or right click on the systray icon and choose Win9x/ShutDown Both (Tool+Server). If a confirmation box appear reply clicking the "YES" button.

Apache:
Close Apache shell window.

GuildFTPd:
The quick'n'dirty way is to close the application window and if a confirmation box appear reply clicking the "YES" button. Otherwise you can click on the ON button or choose it from the Admin / Allow Logins (keyboard shortcut Ctrl+Enter) and then choose what to do with eventual currently logged users: Don't kick current users (doesn't accept new users and shuts down the FTP server when all current users leave), Kick current users after transfers (doesn't accept new users and kick the current ones when they finished the downloads they have in progress, then shuts down the FTP server), Kick users now (kick all users immediately and shuts down server).

Close the application.



UNINSTALLING

Apache, MySQL, GuildFTPd, and PostCast server can be removed from the Control Panel with Add-Remove Applications (respectively with Apache HTTP Server x.x.xx , MySQL Servers and Clients x.xx.xx , GuildFTPd FTP Deamon), while to remove PHP and phpMyAdmin you'll have to delete manually their directories. Perl can be removed with Add-Remove Applications only if you used the MSI installer, otherwise you'll have to delete manually its directory.



UPGRADING

To upgrade one or more of these products, follow the instructions to uninstall them and then install them as if it was the first time.

Make a back'up of the configuration files, although you will not able to use them with newer version you can still use them to compare and update manually the new configuration files:
the whole conf directory (or at least httpd.conf) for Apache
php.ini for PHP
my.cfg for MySQL

If you've started MySQL you'll have to reboot before to launch the SETUP, after uninstalling.



See also How to install LAMP (for Debian GNU/Linux)