Apache 2.2 + Tomcat 6.0 on Windows XP
by Douglas McGregor on Aug.10, 2009, under Geeky Stuff
After spending about at least a few days researching and implementing this topic, hard work has finally paid off.
Requirements for this tutorial:
- Intermediate knowledge of the HTTP Protocol
- Basic knowledge of Windows XP (e.g. how to navigate folder directories)
- Java Runtime Environment 5.0 (JRE)
- A glass of water, cup of tea, cider, or whatever floats your boat
- About an hour to spare
Since there isn't a tutorial out there that deals specifically with Apache 2.2 and Tomcat 6.0 on Windows XP, I thought I would do the honours. First of all, download and install Apache – I prefer AppServ – and download and install Tomcat. Check it works by browsing to localhost and localhost:8080 respectively. If so, we are ready to follow the next steps.
-
Download mod_jk (the file name should be mod_jk-1.2.28-httpd-2.2.3.so)
-
Copy to C:\AppServ\Apache2.2\modules and rename to mod_jk.so -
Open the Apache httpd.conf file (found in C:\AppServ\Apache2.2\conf) and add the following line:
LoadModule jk_module modules/mod_jk.so
- Open Tomcat's server configuration file (C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\Server.xml)
- Look for the line that says:
<Server port="8005" shutdown="SHUTDOWN" debug="0">
- Add the following line directly after it:
<Listener className="org.apache.jk.config.ApacheConfig" modJk="c:/
AppServ/Apache2.2/modules/mod_jk.so" workersConfig="C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/workers.properties" />
- Just below this line:
<Host name="localhost" appBase="webapps" unpackWARs="true"
autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
- Add this:
<Listener className="org.apache.jk.config.ApacheConfig" append="true" forwardAll="false" modJk="c:/AppServ/Apache2.2/modules/mod_jk.so" />
- Restart the Tomcat service
- If all goes well, you should find that a new directory has been added – C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\auto with a file called mod_jk.config in it
- Edit the Apache httpd.conf file. Add the following
Include "C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/auto//mod_jk.conf"
- Create a file called workers.properties in tomcat/conf/jk, and add the following lines to it:
# BEGIN workers.properties
# Definition for Ajp13 worker
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
# END workers.properties
Restart the Tomcat service and Apache service. You may need to reboot in Apache's case – it seems fussy about that on Windows XP. I still needed to make a few modifications to my setup in order for it to work properly. The first time I restarted Apache I got a message saying:
Useless use of AllowOverride
In order to solve this error, I had to create a custom mod_jk.conf file, and delete all the AllowOverride None statements. After doing this, you will no longer be able to use the auto generated file. Rename the file to mod_jkCustom.conf and save it to C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf. Update your Apache httpd.conf file as follows:
Include "C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/mod_jkCustom.conf"
Restart Apache and reboot Windows. Now navigate to localhost and localhost:8080 to check that both servers are running. If all is well, navigate to localhost/examples. You should get error 403, forbidden. This is far better than a 404 error, at least it's working.
In order to fix this, look for the following in the Apache httpd.conf file:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Satisfy all
Deny from all
</Directory>
Change "Deny from all" to "Allow from all". This seems to be the only thing that works. Restart Apache and restart Windows. Navigate to localhost/examples. You should get a surprise. It works!
I hope this has helped someone out there. I had previously tried unsuccessfully to do this on IIS, which seems slightly more complicated, but considering I'm using Windows XP Home Edition, I won't be using IIS for the near future. Apache seems to serve all my needs for the time being.
Hope everyone has a good weekend!

September 23rd, 2009 on 23:39
works! changed the line Include “C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/auto//mod_jk.conf” to end of file.
September 23rd, 2009 on 23:27
Hello, i have win2003 server and did not work. both localhost and localhost:8080 works. i should place de php and jsp files at the same folder right? PS: i did not use the mod_jkCustom.conf (not winxp) Thanks
August 5th, 2009 on 02:46
Thanks – very useful! Worked perfectly. Saved me a lot of time. I like the auto generated mod_jk.conf – I’ve never seen that before.