Installing an Apache server on Windows
This is an old version (11 june 2006) of our tutorial. For the latest version, see
here.
Introduction
This tutorial will guide you, step by step, through the installation of Apache, along with PHP and MySQL (and phpMyAdmin), under Windows.
For this tutorial, we used apache_2.0.54-win32-x86-no_ssl.msi, php-5.0.4-Win32.zip, mysql-essential-4.1.12a-win32.msi and phpMyAdmin-2.6.3-pl1.zip, on a machine running Windows XP Home SP2 (but this tut works fine with XP Pro, but there is a little problem with Win 2000 - but that won't prevent you from running the full server though).
Warning : in this tutorial, we are configuring a server that will send error and warning messages that will help you for development, but may reveal security breaches to potential hackers. So, DO NOT use this server for hosting purpose, use it only for development (unless you edit the configuration files as appropiate).
Note : this tutorial doesn't work with Apache 2.2.x (different httpd.conf file and the PHP 5 module doesn't support this version yet). Please use Apache 2.0.x for the moment.
Summary
All links
- Apache HTTP Server (download page). Choose Win32 Binary (MSI Installer).
- PHP (download page). Choose the zip package in the Windows Binaries section.
- MySQL (download page). Choose the latest stable version, then choose Windows Essentials (x86).
- phpMyAdmin (download page). Choose whichever file you want (the zip may be simpler to use though).
Apache
Running the installer
On the
Server Information screen :
- in Network Domain, enter your domain name if you own one, or anything you want (it's not important but this field is mandatory). We entered patheticcockroach.com.
- in Server Name, enter your domain name with www. before. We entered www.patheticcockroach.com (not important either, but mandatory too).
- in Administrator's Email Address, enter your e-mail if you want to, or any nospam@IwontgiveMyAddress.com :). We entered our real e-mail (not important either, but mandatory too).
- check Install Apache HTTP Server 2.0 programs and shortcuts for only for the Current User, on Port 8080, when started Manually.
On the
Setup Type screen : choose
Custom.
On the
Custom Setup screen : choose what you want to install. You can leave all the default values if you want. We left the default component settings (full installation), and changed the install path to
C:\Program Files\SERVER\Apache Group\.
Configuring Apache
First, let's remove a useless feature : open the
Start menu, go to
Programs → Startup and delete
Monitor Apache Servers. In the taskbar, you can locate and exit the
Apache Monitor if you want. That's what we did.
Then, go to your Apache folder (for us it's
C:\Program Files\SERVER\Apache Group\Apache2), and open
httpd.conf (located in the
conf folder). Here are a few important parameters (there is more help about them in the
httpd.conf file itself, so we just list them) :
Result
Congrats, you're done with Apache ! Wanna see the result ? Okay, but not too long, we still have some work to do.
In the
Start menu, go to
Programs → Apache HTTP Server 2.x → Control Apache Server → Start Apache in Console. Huh ? It's rather raw, isn't it ? Don't worry, that's not your site :).
Put some html pages in the folder you entered in the
DocumentRoot field (see above).
Open your favorite browser (I hope it's not MSIE, btw ;)), and in the address bar, type
http://127.0.0.1:8080 Here are your pages, and you could share it with anyone on the web, if they had your IP and if you let Apache go through your firewall.
PHP
Close Apache (not mandatory but let's act cleanly).
Unzipping the stuff
Extract your php file (for us it was
php-5.0.4-Win32.zip) in some folder. We extracted it in
C:\Program Files\SERVER\PHP.
Configuring PHP
Go to your PHP folder (for us it's
C:\Program Files\SERVER\PHP). Copy
php.ini-dist as
php.ini, and open this
php.ini.
Configuring Apache to work with PHP
Go to your Apache folder and open
httpd.conf (located in the
conf folder) :
- add
LoadModule php5_module "C:/Program Files/SERVER/PHP/php5apache2.dll"
PHPIniDir "C:/Program Files/SERVER/PHP"
at the beginning of the file (of course, replace the path by yours).
- search for
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
and add AddType application/x-httpd-php .php .phtml after it (needed for PHP).
- search for
#
# Action lets you define media types that will execute a script whenever
# a matching file is called. This eliminates the need for repeated URL
# pathnames for oft-used CGI file processors.
# Format: Action media/type /cgi-script/location
# Format: Action handler-name /cgi-script/location
#
and add Action application/x-httpd-php "C:/Program Files/SERVER/PHP/php.exe" after it (needed for PHP, replace the path by yours).
In your PHP directory (for us,
C:\Program Files\SERVER\PHP), copy the file
libmysql.dll and paste it into the
bin directory of your Apache folder (ie, for us
C:\Program Files\SERVER\Apache Group\Apache2\bin).
Hello World
Well, time for another break. With notepad, create a file named somename.php, containing :
<?php phpinfo(); ?>
Save it into your server directory (for us it's
C:/SERVER/HTTP). Now launch Apache. With your browser go to
http://127.0.0.1:8080/somename.php. You should see a page listing a lot of things about your server :)
MySQL
Close Apache (not mandatory but...)
Running the installer
On the
Setup Type screen : choose
Custom.
On the
Custom Setup screen : choose what you want to install. You can leave all the default values if you want. We left the default component settings (full installation), and changed the install path to
C:\Program Files\SERVER\MySQL\MySQL Server 4.1\.
On the
MySQL.com Sign-Up screen : do whatever you want... we chose
Skip Sign-Up.
On the
Wizard Completed screen : leave the
Configure the MySQL server now checkbox ckecked. This opens the MySQL Server Instance Configuration Wizard.
Configuring MySQL
If it isn't already opened, launch the MySQL Server Instance Configuration Wizard (In the
Start menu, go to
Programs → MySQL → MySQL Server 4.1 → MySQL Server Instance Config Wizard).
On the
Please select a configuration type screen : choose
Standard Configuration.
On the
Please set the Windows options screen : uncheck
Install As Windows Service.
Creating the links to launch and close MySQL
Go to the
bin folder in your MySQL folder (for us it's
C:\Program Files\SERVER\MySQL\MySQL Server 4.1\bin).
Create a file called
MySQL_launch.bat (you can choose another name, but
the extension must be .bat), right-click on it and choose
Edit. In the notepad windows that appear, type
mysqld-nt.exe
and save and close the file.
Create a file called
MySQL_stop.bat right-click on it and choose
Edit. In the notepad windows that appear :
Now, to launch the MySQL Server, all you have to do is run
MySQL_launch.bat. To close the MySQL Server, run
MySQL_stop.bat. You can create a link to these batch files and put these links in the start menu, but this tut isn't the place to explain this).
If you get stuck because of these files, tell us on the forum : we can send you our batch files.
Result
Sorry, nothing new to see here. Move on to the next section, there'll be much more things to see.
phpMyAdmin
Unzipping the stuff
Extract your phpMyAdmin file (for us it was
phpMyAdmin-2.6.3-pl1.zip) in a folder
within your server's folder. We extracted it in
D:\SERVER\HTTP\Restricted\phpMyAdmin. Move all the files and folders into
D:\SERVER\HTTP\Restricted\phpMyAdmin (instead of leaving them in the original
D:\SERVER\HTTP\Restricted\phpMyAdmin\phpMyAdmin-2.6.3-pl1).
Configuring phpMyAdmin
Open
config.inc.php (in your phpMyAdmin directory) with Wordpad (it contains caracters not compatible with notepad) :
- search for $cfg['PmaAbsoluteUri'] and indicate here your phpMyAdmin path, using your domain name or IP. Eg :
- you can try to leave it empty, it works fine with recent versions of phpMyAdmin
- you can use 127.0.0.1 (this is how your PC refers to himself, but if you use it, you won't be able to access phpMyAdmin from another computer)
- you can use 38.107.191.102 (your IP, then you'll be able to access phpMyAdmin from anywhere on the internet, provided that your firewall or your network is properly configured and that you have a constant IP)
- you can use your local IP if you have a local network (then you will be able to access phpMyAdmin only from a computer on this network)
- you can use your domain name, if you have one and know how to configure it to work with your Apache installation (I don't know how to do).
We set this to http://192.168.1.104:8080/Restricted/phpMyAdmin/, which is our IP on our local network.
Launch Apache, and with your browser, go to
http://127.0.0.1:8080/Restricted/phpMyAdmin/ (or to wherever you installed phpMyAdmin).
Click on Privileges, then edit the root account to add it a password. Then, you'll be kicked from phpMyAdmin, since you set a new password :).
Open
config.inc.php again, search for
$cfg['Servers'][$i]['password'] and enter your password there.
In your browser, hit F5 to reload phpMyAdmin. Click on Privileges, then Edit the Any account and remove all privilieges.
Here you are, phpMyAdmin is configured.
Just a last security feature
You probably noticed that you don't need any password to use phpMyAdmin, which means that virtually anyone can access your database through phpMyAdmin. Let's add some protection.
To sum up : for instance, we have 3 files :
Now go back to your browser, to
http://127.0.0.1:8080/Restricted/phpMyAdmin/ : it asks for a username and a passord, for us it's
patheticcockroach and
mypassword.
Finally
Congrats, you now have a brand new Apache HTTP Server with PHP and MySQL support, running phpMyAdmin as a database administration tool.
What's more they won't launch by themselves, since we remove their startup entries as they added them. And your phpMyAdmin folder (and perhaps other folders, or even your whole server) is secured by a password.
Do not forget to keep links to
Apache.exe (in the bin folder of Apache),
MySQL_launch.bat and
MySQL_stop.bat (in the bin folder of MySQL).