Setting up the Redmine Front End

In the previous post, I spent a lot of time setting up a centralized git service, accessed via ssh using gitolite.  Now I want to get a Redmine installation going as a front end for gitolite, and for other types of tracking in general.  This is especially a good option if you are a small organization that also needs project and ticket tracking for a number of repositories.  This involves a lot of steps, some I’ll step through quickly without a lot of information, and some I’ll spend more time on, but in this tutorial you will complete the following:

  1. Install and create a new database for storing data for Redmine.
  2. Create the users and roles for accessing the Redmine database from redmine.
  3. Install Redmine and complete database deployment
  4. Install and configure Apache for redmine
  5. Test Redmine.

Edit: This is the second in a four part series about gitolite and Redmine, ending with full automation. The other articles are:

Ok, let’s continue…

Most of these applications are way too large and unwieldy to describe full application and configuration handling in one go, so I’m going to assume that you are using Ubuntu 12.04 and apt-get.  Ubuntu 12.04 server is the most recent version of Ubuntu at the time of this writing, and apt-get makes the installation of most of the things necessary for this activity very easy.  If you are still trying to set up the gitolite service that I mentioned in the first blog post, there is still time to turn around and set up a GitHub account and just be done with it.  I wouldn’t blame you if you did, but I imagine you are getting tired of me saying so

Install and create a new database for storing data for Redmine

For this effort, we are going to use a PostgreSQL database. There are many open source databases that you can use for this effort, and I don’t want to get into a holy war; it is the one that I know best. I want to search for the right repository to install, and it wasn’t obvious to me what it was when I started this tutorial, so I went ahead and ran:

$ apt-cache search postgresql | less

To get the paginated results for items that I can install using apt get related to postgresql. Part way down, I found the server, and completed the installation with

$ sudo apt-get install postgresql-9.1

And was done with the installation.

The installed database can only be reached by one user at the moment, according to the configuration that it has by default.  This user is password-less access from localhost as the user postgres. Thus, you can log in with administrators access to the box using the following command:

$ sudo -u postgres psql

Meaning, run psql as the user postgres. This should give you general access to the postgres database. Now we will create the necessary database for redmine (which we can change with configuration later):

postgres=# create database redmine_default;

And now we have a database backend for redmine, but it doesn’t have any tables or users.

Create the users and roles for accessing the Redmine database from redmine

We can do this in one of two ways. Either we can start by installing redmine and using the configuration file for the new password, or we can create the user here and modify the configuration to match what we have created. I am going to do the latter, creating a user ‘redmine’ with password ‘redmine_pass’ for easy work.

postgres=# create user redmine password 'redmine_pass'
postgres=# grant all on database redmine_default to redmine;

You should test this configuration using the following:

$ psql --host=localhost --dbname=redmine_default -U redmine -W
Password for user redmine: 
psql (9.1.4)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.


And now the database is ready for configuration and activity by redmine.

Install Redmine and complete database deployment

Installing redmine is just as simple as installing the postgres database:

sudo apt-get install redmine-pgsql redmine

The first object, redmine-pgsql, will install postgresql handling for redmine.

During the run, it will ask if you want to configure some things. When you do, you will need to answer the questions to the best of your ability to do some, and some of the answers are clear to you as you go, as they will be part of the questions that I have pointed out during the process of the doing this installation up to this point.

If you run into problems after configuration when it tries to build out the database (it didn’t do something properly), then use the command sudo dpkg-reconfigure redmine to reconfigure and try to redeploy the database.

After the database has been deployed, connect to the database again as the redmine user and database redmine_default and use the command ‘\d’ to list all of the tables in the redmine_default database.

Install and configure Apache for redmine

Often, when you deploy a website style application using apt-get it will configure some service and have a port open for you right away. With redmine, that doesn’t exist, although it probably has a testing start up that I don’t know about because I don’t do rails programming (yet). What I do know, though, is how to set up Apache to run a rails application, which would be useful to anybody working with rails. We will set up a new available site on a new port, that way if you want to run it on port 80 later, you can place something in front of it, like HAProxy or Varnish, and thus have a more stable system. The port that I will use will be 8901 (just because I can).

There are five parts necessary for getting redmine running in Apache on an Ubuntu server (and probably any server, really):

  1. Install the Apache server.
  2. Validate that passenger plugins are installed for Apache.
  3. Create a new available site for Apache that points to Redmine.
  4. Enable the site for redmine in Apache.
  5. Open the port in Apache so that it can be accessed.

These are the activities that should be done for all new services that will run under Apache, IMHO.  It is much easier to modify the ‘default’ site, and just give each item a new directory, but it is much cleaner and far easier to turn parts on and off if you instead configure everything this way.  Most other tutorials I have read go for the alternative, and I would strongly advise against it, as directory structure for each application would be best handled by that application, I think.

First, we install the Apache server:

$ sudo apt-get install apache

This installs the apache libraries, but what we really want to see is the configuration under /etc/apache2, where we will find a number of new files. Under the mods-available directory, you will notice that passenger, by default, is absent. I went ahead and used apt-cache search to find the passenger module I would need, and installed it.

$ sudo apt-get install libapache2-mod-passenger

What Passenger gives us is the ability to run Rails applications in Ruby, similar to mod-perl, etc. After you have run the command, you should be able to easily find passenger.load and passenger.conf files under mods-available and mods-enabled.

Now, we need to create a new available site. The new site will have new logging locations and the new port I described earlier, 8901. This might not be the best port (might be common in another application), but it can be changed kind of at will, especially if you ever put up an HAProxy or Varnish front end, as I mentioned earlier. We need to edit the new site configuration file first, then link it in the enabled sites. First we edit the file /etc/apache2/sites-available/redmine-default, and put in the following:

<VirtualHost *:8901>
    PassengerDefaultUser www-data
    RailsEnv production
    RailsBaseURI /
    SetEnv X_DEBIAN_SITEID "default"
    Alias "/plugin_assets/" /var/cache/redmine/default/plugin_assets
    DocumentRoot "/usr/share/redmine/public"
    <Directory "/usr/share/redmine/public">
        Order allow,deny
        Allow from all
    ErrorLog /var/log/apache2/redmine-default-error.log
    CustomLog /var/log/apache2/redmine-default-access.log combined

Now we need to install this as an enabled site in order for it to appear. We do this by running the following:

$ sudo ln -s /etc/apache2/sites-available/redmine-default /etc/apache2/sites-enabled/redmine-default

Please note that if you don’t know how to use vim or emacs, you are probably going to have a really bad time. You should spend some time learning one or the other now. I prefer vim, but the battle between the two is a bit of a holy war. Get good with one and stick with it.
Restarting Apache at this point for testing is not a bad idea, but will not open port 8901. Run the following for testing only:

$ sudo service apache2 restart

And you might see some warnings, but we are overall ok at this point as long as no errors occur from the config. Now we need to get apache2 listening on the port 8901. We edit the file /etc/apache2/ports.conf and add in the following lines:

NameVirtualHost *:8901
Listen 8901

Then restart apache2 again.

At this point in the document, I could spend several paragraphs, heck, a book on how to configure and work with Apache2. You can learn that on your own. What I can tell you though is that if you want to get 100% out of Apache2, you should spend some time learning it. You might need to learn the difference between packages like apache2-mpm-prefork and others, etc. Either way, please note that what I have done above it not exhaustive, but like sunscreen, if you take anything away from what I’ve done in this situation, it’s that you break up your available sites into separate configurations, the same as you should do if you find yourself needing to configure an application to handle multiple instances on any box.

Test Redmine

To to http://<hostname&gt;:8901/ in your browser. Did it work? If not, look back over the steps and figure out what either you did wrong, or I did wrong. If I messed up, send me a comment and I’ll fix it. Please note that the default password for Redmine is admin/admin. You may at this point wish to set up some users or the entire login model to use LDAP or Active Directory (which is beyond the scope of this article), but if you have them, it is a good idea to learn and use them for all login applications for your organization.

Now, if you’ve followed the previous tutorial referencing gitolite, then we should nearly be able to use Redmine to take over the administration of gitolite for us, and thus be able to make new developers nearly able to act for themselves, handle multiple projects, etc. That will be covered in my next and final article in the current series.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: