This article was written after a successful upgrade of my local server running on Win XP SP2. I started out with Apache 2.0.59, PHP 5.1.5 and MySQL 5.0.24, and are now running PHP 5.2.0 and MySQL 5.1.4 on Apache 2.2.3.
If you are starting a fresh install please see the following articles, as the installation procedure hasn’t changed much from previous versions:
- How to install Apache 2 on Windows
- How to install PHP 5 on Windows
- How to install MySQL 5 on Windows
Some thoughts before upgrading
As some of you already know PHP 5 versions prior to 5.2.0 is not automatically supported by Apache 2.2.x, therefore I thought it would be a good idea to upgrade PHP before starting the server upgrade. It also seamed like a good idea to completely remove Apache 2.0.x before continuing since version 2.2.x is such a massive upgrade. This article also assumes you have installed Apache, MySQL and PHP to the following locations: C:\Apache2, C:\mysql and C:\php5
Updating PHP to version 5.2.0
I started out with stopping the Apache 2 service (click the Apache icon next to your tray clock and choose stop). Open Windows Explorer and rename C:\php5 to e.g. C:\php5_backup. Download the latest version of PHP 5 (Windows binaries – PHP 5.2.0 zip package) and unpack it (unzip) to C:\php5. Then open php.ini-recommended found in C:\php5 and change the settings to equal your previous php.ini file and save it to the same dir as your new php.ini. Below is a brief summary of the changes I made to my php.ini file:
;Language Options short_open_tag = On ;Resource Limits max_execution_time = 30 max_input_time = 60 memory_limit = 16M ;Error handling and logging error_reporting = E_ALL & ~E_NOTICE display_errors = On html_errors = On docref_root = "/phpmanual/" docref_ext = .html error_prepend_string = "<font color="#ff0000">" error_append_string = "</font>" ;Data Handling register_globals = On ;(Optional) register_argc_argv = On ;(Optional) ;Paths and Directories doc_root = C:\\Apache2\\htdocs extension_dir = "C:\\php5\\ext" ;Dynamic Extensions extension=php_mbstring.dll extension=php_gd2.dll extension=php_mysql.dll
Since this installation is meant for development I’ve set “display_errors” and “html_errors” to On. Note: If you are running a production environment I recommend you leave all settings under “Error handling and logging” default. The same goes for “Data Handling”.
To enable html_errors you need to unzip the PHP Manual into the following folder C:\Apache2\htdocs\phpmanual (choose the “Many HTML files” distro).
Uninstalling Apache 2.0.xx
To uninstall Apache 2 simply click Start –> Controlpanel –> Add or Remove Programs then select Apache from the list and hit Remove. After the unimstall reboot your PC and verify that the Apache service is not running by clicking Start –> Controlpanel –> Administrative Tools –> Services. If it’s still listed (and / or running) follow these steps in order to remove the service:
- Click Start –> Run and type in Regedit or regedt32
- Find the registry entry: HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services
- Find the service there and delete it. You may wish to look at the keys and see what files the service was using and perhaps delete them also.
Note: You will have to reboot before the list gets updated in the service manager.
Finalize by removing all files and directories except the htdocs directory under C:\Apache2 as this directory contains all your working files (most likely anyway).
Installing Apache 2.2.x
Now that you have a “clean” system continue by installing Apache 2.2.x. Download the latest version of Win32 Binary (MSI Installer). At the time I wrote this article the file was named apache_2.2.3-win32-x86-no_ssl.msi. Then do the actual installation like I’ve described earlier in my article on “How to install Apache 2 on Windows“.
To configure Apache to load PHP5 as a module to parse your PHP scripts, use a text editor to open the Apache configuration file, httpd.conf, typically found in C:\Apache2\conf.
Next, add the following lines at the bottom of this file:
# PHP 5.2.0 running as an Apache module: LoadModule php5_module "C:/php5/php5apache2_2.dll" AddType application/x-httpd-php .php .phps .php3 .phtml .asp PHPIniDir "C:/php5"
Now all that remains is to add some variations of index files to the DirectoryIndex. Replace the DirectoryIndex line with the following:
DirectoryIndex index.htm index.html index.php index.html.var
Note: Sometimes you may have to reboot your PC twice to get Apache to function properly. Happened to me and I believe it might be a Windows bug (again)…
Updating to MySQL 5.1.x
In order to move from MySQL 5.0 to 5.1 I started out with updating MySQL to the latest version in the 5.0 series to make the upgrade as smooth as possible. The procedure is explained in my article on “How to install MySQL 5 on Windows“.
To finalize simply follow the exact same procedure again, but this time using the similar Windows Essentials (x86) version from the 5.1 series found at http://dev.mysql.com/downloads/mysql/5.1.html.
If everything went well you should now be running all the latest versions of Apache, MySQL and PHP. You can test your new system by installing phpMyAdmin.
5 Comments on “Upgrading to Apache 2.2”
Thanks for taking the time to write such an excellent tutorial. Suppose its meant to be a personal “memo” as well… Well even better!
Took me less than an hour to get everything up and running, which is excellent given my computer skills 😉
Well that’s sweet – shouldn’t be hard as long as you follow the guidelines…
Installing Apache, PHP, MySQL, etc, by hand under Windows can be an enlightening experience.
Though if you are looking for an easier way, just download the Web-Developer Server Suite.
Thanks for the tip! It looks fine, haven’t tried it yet though but then again I’m a control freak and have a very special setup which I like to keep as-is for the moment. Might try it on the PC’s at the office though.
Is it as easy to update as to install by the way?
Comments are closed.