Creating a Java build server on windows
SVN – Version Control.
Apache httpd server – Serve contents
Java – Required to build java projects (duh), needed by nexus, tomcat and maven.
Tomcat – Required to run Hudson (note Hudson will work on other application containers, tomcat is my container of choice)
mod_jk – Maps apache to tomcat etc. Note again there are other ways of doing this.
Hudson – Kicks off maven builds and deploys to maven.
Nexus – Binary repository manager
Trac – ticket system and repository browser
python – required by trac
Mod WSGI – required to map python to Apache.
Chosing an install directory.
It simplifies maintaince if all the applications can be installed to the same place. For the purposes of this post I’m going to install to a folder under c:/services.
IIS was currently running on the server. To stop IIS I went to the command prompt and types iisreset /stop followed by iisreset /disable.
Then go to services and disable the IIS Admin Service.
Installing Apache httpd
For this I’m going to download the latest apache server. At time of writing the latest server is 2.2.16. We are going to chose the win32 binaries because thats what are available on Apache and if we run into problems we are more likely to see other people with the same problems.
Choosing the Open SSL version as thats easier.
Binaries can be found at
Stepping through the installation steps until the point of Network Domain is reached. For the network domain I’ve chosen
server name will be
Email address my work email address.
Chose for all users on port 80 (The recommended setting).
I’m going to choose a custom installation as I wish to chose an install directory.
Choose not to install the documentation as the documentation on Apache.org is sufficient. I’ve opted to include the Build Headers and Libaries in case we ever need to compile something against this apache.
Remove APR Iconv Code Pages as its not required.
Choose the root option “Apache HTTP Server 2.2.16” and change the install location to your install directory. c:\services\apache\
Okay now to test the configuration. We just want to be sure it launches we can harden the server later. From the start menu under apache choose “Test Configuration”. This opens up a window with some text which just flashes up and disappears.
I get the following error:
httpd.exe: Could not reliably determine the server's fully qualified domain name
, using 10.10.14.3 for ServerName
Okay this is fixable. Basically I need to change the definition of server name in httpd.conf c:\services\apache\conf\httpd.conf
Looking in httpd.conf I see the following lines.
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
# If your host doesn't have a registered DNS name, enter its IP address here.
We need to uncomment the ServerName entry.
rerunning the test gives Syntax okay.
Finally to start apache we run the following command
c:\services\apache\bin\httpd -k start
If it starts navigate to localhost and ensure you are seeing contents. I see “It works!” which supprisingly means it works 🙂
Python is needed for trac. Lets get on and install that next.
Python can be downloaded from http://www.python.org/download/ . Trac utilises python 2 so we will give python 2 a go.
At the time of writing python (2) is at version 2.7 Thats the version we are going to get. Also as there are a few issues surrounding the 64 bit version and it needs to match the apache version. We are going to choose the 32 bit version. Python 2.7 Windows installer
Choose install for all users. The default install directory is c:\Python27\ but we are going to change that to c:\services\Python27\
Going for a complete install here basically choose all features and install.
With a bit of luck python now works.
Download a version of subversion. I’ve chosen the silksvn binaries avaliable from http://www.slik.com/en/download.
Connecting to apache.
Easy install is a python script that makes updating other python scripts easier. It can be found at http://peak.telecommunity.com/dist/ez_setup.py
Run the script in python.
This installs setuptools
Mod_WSGI can be found at http://code.google.com/p/modwsgi/ you need to choose an appropiate one for your version of python and your version of apache. In our case it will be mod_wsgi-win32-ap22py27-3.3.so – Apache 2.2 / Python 2.7
Copy to c:\services\apache\modules. Rename the module to mod_wsgi.so
LoadModule wsgi_module modules/mod_wsgi.so to apache conf and restart
In the c:\services\Python27\scripts run easy_install trac. This should install trac. Next we need to setup a trac repoisitory. In the same directory run trac-admin.exe c:\services\trac initenv. You will be asked a few questions. Enter the values you want. For database you can just use the default.
The next step is to deploy the trac creation script to a new document root for trac. I’ve chosen c:\services\trac_www as the web root for trac.
trac-admin.exe c:\services\trac deploy c:\services\trac_www
Mapping trac to apache
Find the wsgi file created by the above script. On my computer this is in c:\services\trac_www\cgi-bin
Add the following to your httpd.conf
WSGIScriptAlias /trac c:/services/trac_www/cgi-bin/trac.wsgi
Allow from all
Test in apache now. On the same machine as you are viewing go to http://localhost/trac/ . If you have a forbidden message it may be because permission is removed from directories.
in you httpd.conf find the following
Deny from all
Change this to
Deny from all
Allow from 127.0.0.1
And restart apache “c:\services\apache\bin\httpd -k restart”
With any luck you should now see trac installed.
Download maven as a zip file. Inside you should see a folder called “apache-maven-2.x.x” copy this folder to wherever you want maven isntalled.
In our case this creates a folder called c:\services\apache-maven-2.x.x\
Add maven to the command line.
Download windows installer service. Install using the defaults.
Remove HTTP connector. Remove all comments from server.xml
Add a worker.properties file with the following contents in the apache conf directory.
# Define 1 real worker using ajp13
# Set properties for worker1 (ajp13)
Add the following directives to apache
JKMount /manager* worker1
Hudson can be downloaded from http://hudson-ci.org/latest/hudson.war
Set the following environement variables
HUDSON_HOME = c:\services\work\
copy the hudson war into your tomcat webapps directory.
Add a mount argument so requests to /hudson are passed to the worker.
JKMount /hudson* worker1
At this point you should restart apache and tomcat to ensure its all working. Hudson requires UTF-8 Urls so in your server.xml you should put URIEncoding=”UTF-8″