So as part of a project I am working on I need to have a development server that will allow me to run a number of development tools, specifically JIRA, Confluence , Subversion, and MySQL but later maybe some other tools.
First I looked at the options for hosting. I would need a host wher eI could run tomcat and apache, this really meant a dedicated server or a cloud service. After a quite look into a number of providers I plumpted for a Rackspace Cloud Server. Sign up was astraight forward and after a phone call from Rackspace to confirm my details I was ready to create my first VM. This was very easy using their web based front end and within 10 mins I had a new Ubuntu 10.04 LTS Server up and running and was able to logon with SSH.
Security
So how to configure this new server. Since Rackspace give you root access it was nessassary to secure the server. This involved logging on as root and seting up two new groups, sshlogins and admin, adding a newuser, putting the newuser in both the groups:
Next we need to restricting ssh to the new sshlogins group only. To do this edit the /etc/ssh/sshd_config file, find where it says PermitRootLogin yes and change it to PermitRootLogin no then at the bottom of file add:
for this to take effect the sshd needs to be restarted:
And finally allowing the admin group to perform sudo actions. This involes editing the /etc/sudoers file, however as this is so important this needs to be done using visudo, adding the following line at the bottom.
Then save the file.
Now logout of root and log back in again as newuser
Next we need to stop any connections to ports except those we wish to have access through, i.e. 22 (for SSH) and 80 (for the Webserver). To do this will be use the inbuilt iptables, however to make life easier we will use ufw to configure the firewall. To do this first you will need to install ufw:
And configure the firewall as follows (thanks for Mike Descy at 101Umbrellas):
Installing base software
The base software for this installation is JIRA, Confluence , Subversion and MySQL. To install these and the other required components tomcat6-user for the private instance features of tomcat and ttf-dejavu for the fonts required as the server is installed with X11 use:
Configuring MySQL
MySQL needs to have some options set so it can work for Jira and Confluence. The easiest way to do this is to edit /etc/mysql/my.cnf and add the following lines at the end of the [mysqld] section just before the [mysqldump] section start
And then restart MySQl
Now we need Databases and users for Jira and confluence. To create these logon to the mysql console as root and enter:
Configuring Tomcat for Jira and Confluence
The tomcat6-user is required later for creating the separate tomcat instances
Confluence and Jira will need home directories as does tomcat for it's server instances, I put these in the /srv directory where the tomcat instance will also live eventually
We are going to create two new tomcat instances one for jira and one for confluence. Here we are setting the HTTP connection ports to 8090 and 8091 respectivly and the control ports to 8015 and 8016. Once the server instances are created the Catalina/localhost directories need to be created for each of the new tomcat instances
Since Jira and Confluence require some extra jars to work, namely those in the http://www.atlassian.com/software/jira/downloads/binary/jira-jars-tomcat-distribution-4.3-rc1-tomcat-6x.zip and the MySQL JDBC driver these need to be downloaded and put into the system-wide tomcat /usr/share/tomcat6/lib directory.
Next we need the .war files for Jira and Confluence. These need to be compliled and I suggest you do this on a seperate machine and follow the Atlassian instructions for Jira and confluence to build .war files and then copy the .war files to the live server ready for deployment to the tomcat instances.
Web configuration files for Jira and Confluence need to be created before starting the servers. For Jira the file, /srv/tomcat/jira/conf/Catalina/localhost/jira.xml should contain:
And for Confluence, something very similar the file, /srv/tomcat/confluence/conf/Catalina/localhost/confluence.xml should contain:
To set the memory allocation settings for Tomcat edit both jira/bin/setenv.sh and confluence/bin/setenv.sh and add the following line at the end:
Next you need to stop the default tomcat instance from automatically starting and set the Jira and Confluence instances to automatically start. To do this you need to create, and make executable, /etc/init.d/jira and /etc/init.d/confluence scripts as:
/etc/init.d/jira
/etc/init.d/confluence
And make them executable:
Then it is necessary to disable the default tomcat instance and enable the jira and confluence instances. Thanks to http://www.debuntu.org/how-to-manage-services-with-update-rc.d for this. Anyway here are the commands you need:
Startup Jira and Confluence:
Configuring Apache HTTPD
There are a number of things to configure in Apache. First you need to enable the proxy modules as these are required for the Proxy rules that are required. To do this:
Next the default site configuration file, /etc/apache2/sites-enabled/000-default needs to be edited to set the ServerName, ServerAdmin and DocumentRoot properties as such:
Then the proxy rules sections need to be added at the bottom of the file, but before the closing tag:
I like to put a basic index.html file in the /srv/www directory that allows users to find the Jira and Confluence sites. I use something like:
And restart Apache:
Configuring Subversion
This is fairly easy, I have decided to use http as the access method and thanks to the Ubuntu documentation on Subversion all you need to do is:
You then need to add the following to the Apache config file /etc/apache2/sites-enabled/000-default, after the previously added proxy sections but before the final tag:
Then you need to add a password for any users, the -c option is required for the first user but not any others:
And restart Apache:
Whats Left to do:
This setup all works and is all that is really required. However there are a couple of other things that you may wish to do:
- Start jira and confluence as tomcat6 user - currently the tomcat instances run as root and this has security implications. Making the tomcat instances run as the tomcat6 user adds small amount of security such that if a hacker finds a security hole in tomcat then they only have limited access.
- Configure Apache for SSL - This again adds more security and we can even stop all access to Jira, Confluence and Subversion without going through the SSL version of the site, thus stopping any password snooping