About 5 years after my previous tutorial about installing an Apache+PHP+MySQL server on Windows, the time has come to finally dust it off I think. The main reason why I haven’t updated it for so long was because I started using XAMPP instead (or, actually, XAMPP Lite). But XAMPP isn’t very often updated (and XAMPP Lite is even worse in that matter), and although I’ve managed to manually update PHP 5.3.x from a minor version to another, this isn’t working for the recently released PHP 5.4.
I’m going through the trouble of manual setup in order to get the latest versions, so this guide (not really detailed enough to be called a tutorial I think) will deal with Apache 2.4.1, PHP 5.4 and MySQL 5.5.21. I’m on Windows 7 now (XP wasn’t really an option for >4GiB of RAM), so I picked the 64 bits version whenever available (MySQL – at the time of writing Apache is available in 64 bits but this version doesn’t seem to have a PHP handler yet). For PHP I picked the thread safe binaries because as far as I understood non-thread safe ones are only useful for IIS.
Unzip the archive wherever you want. I put it in
E:\PROGRAMMING\My WAMPP and renamed folder
Apache/conf/httpd.conf in a text editor and:
ServerRoot "c:/Apache24"to match the path where you unzipped Apache (for me:
ServerRoot "E:/PROGRAMMING/My WAMPP/Apache")
Listen 80as you wish. I don’t want my test server to be reachable from the outside, so I replaced that with
- Around lines 72-171 there are lots of modules, uncomment those you want to activate. I uncommented:
LoadModule rewrite_module modules/mod_rewrite.so, which is useful for URL rewriting.
- You may want to also edit:
I don’t think what you put there matters on a private, test server, but you do have to uncomment ServerName, even if you leave its default value then.
DocumentRoot "c:/Apache24/htdocs"to indicate the folder where you’ll place the files you want Apache to server (that would be your development folder I guess). I configured it as
- Just below that, make the same kind of edit to
<Directory "c:/Apache24/htdocs">. Within that section, you might want to remove indexes (optional since this can actually help with development) by replacing
Options Indexes FollowSymLinkswith
Options FollowSymLinks, and probably to replace
AllowOverride Allfor more .htaccess file functionality.
- Because we’ll be using PHP, replace
DirectoryIndex index.php index.htm index.html
- Finally, logs will probably be useless so to avoid clogging them you could replace
Apache is now almost ready to run. Run
httpd.exe -k install (browse with the console to
Apache/bin) to install it as a service, then run
ApacheMonitor.exe to control it (you might want to add it to your start menu, too). If you don’t want to install it as a service, simply running httpd.exe should work fine.
To check if everything is working, open http://127.0.0.1 in any browser. Maybe put a file in your
DocumentRoot folder to check that you’re indeed loading it.
Unzip the archive wherever you want. I put it in
php.ini, and open this
php.ini (NB: there are few differences between the production and development php.ini, mainly around error reporting. You can copy the development ini instead if you prefer):
- Tweak the error reporting as you like. Personally I configured:
error_reporting = E_ALL
display_errors = On
log_errors = Off
extension_dirto its proper value, for instance
extension_dir = "E:/PROGRAMMING/My WAMPP/PHP/ext"
- If you are going to deal with user-uploaded files, you’ll want to tweak
post_max_size(the latest should be greater than
- In the
; Dynamic Extensions ;section, I’ll just uncomment
extension=php_pdo_mysql.dll, for PDO access to MySQL
extension=php_mbstring.dll, for “multibyte” functions such as
extension=php_mysqli.dll, which is required for phpMyAdmin. Also note that you might need to copy/paste the
php_mysqli.dllfile itself into your
Apache/binfolder for it to actually work… funny behavior of this extension (same for the standard php_mysql.dll).
Other extensions of particular interest are
php_gd2.dll(for image manipulation such as CAPTCHAs/turing numbers).
- In the
[mail function]section, uncomment
sendmail_from = email@example.com(and optionally replace that with the address that should appear as sender on e-mails sent out by your server – probably you can leave the default value since we’re just configuring a development environment)
- Some other various interesting settings (I let you figure out what they do, it’s all in the doc – and actually for most of them already all in the sample php.ini file). Note that I mentioned the subsections for easier organization:
expose_php = Off
default_charset = "UTF-8"
allow_url_include = Off
default_socket_timeout = 10
date.timezone = "Europe/Paris"
pdo_mysql.cache_size = 2000
session.cookie_httponly = 1
session.cache_limiter = nocache
session.hash_function = "sha256"
session.hash_bits_per_character = 6
session.upload_progress.enabled = Off
mbstring.func_overload = 7
; Resource Limits ;section has interesting stuff, too.
That’s all for php.ini. Actually, although this is a huge file (about 1860 lines) at the beginning, if you remove all comments and unused options you can end up with a much smaller file, such as mine which currently has only 125 lines.
Calling PHP from Apache
Now that PHP is configured, we need to make the link between Apache and PHP.
First, grab php5apache2_4.dll and place it in your PHP folder.
Then at the end of
LoadModule php5_module "E:/PROGRAMMING/My WAMPP/PHP/php5apache2_4.dll"
PHPIniDir "E:/PROGRAMMING/My WAMPP/PHP"
AddHandler application/x-httpd-php .php
That’s all for PHP. To check if everything works, restart Apache and then for instance create in your htdocs folder a php file with the following content:
<?php phpinfo(); ?>
This time there is an installer, so it’s quite straightforward.
In the installer, we’ll choose custom setup, then remove all components named “development” or “debug” and set the install path to
E:\PROGRAMMING\My WAMPP\MySQL\. At some point you’ll have some ad about MySQL enterprise which looks hell lot like an installer, just hit next a couple of times. Then hit finish (leaving the “launch the MySQL instance configuration wizard” box checked).
In the configuration wizard, choose “standard configuration”, leave the default options (Install As Windows Service, Launch the MySQL Server automatically) unless you prefer otherwise, and finally configure the root password.
All is now already configured, although you might want to change
to UTF-8 in
NB: even though I asked MySQL to install in a specific folder, the jack*** put itself (and notably,
my.ini) in the standard
C:\Program Files\MySQL\MySQL Server 5.5 folder, only leaving data files in the folder where I asked it to install… FFFS…
If you want to be able to quickly start and stop the MySQL service, you can create batch files containing:
net start MySQL
net stop MySQL
Well, that pretty much covers it. You now have a fully functional WAMPP equivalent, and it’s much more up-to-date that XAMPP.
This time I won’t cover the phpMyAdmin installation, because 1) it’s pretty trivial (notably, properly documented unlike interfacing Apache and PHP) and 2) if you really, really need help on this, you can probably still apply what I wrote in the previous tutorial, so read on there.
However, if all you want is to quickly set up phpMyAdmin, without using the GUI and without much tweaking, you can just copy the sample config file as config.inc.php, and add/edit those lines, which will allow connection without the need to type login credential and will remove the highly annoying warning message about configuration storage:
$cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = 'xxxxxx'; // your password here $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['PmaNoRelation_DisableWarning'] = true;