Thursday, March 25, 2010

Installing Redmine on Ubuntu 9.10

A week or so ago, I installed Redmine to use for project management for a team of developers and for myself on other projects.  It took awhile and some gathering from different sources to be able to actually get it installed and to be able to use the passenger module for Apache so that it would run Ruby-on-Rails.  I'm not that familiar with Ruby, so this may be common sense, but I figured I would write up what I did for an Ubuntu installation that hasn't been using Ruby at all.


Install prereqs (Make sure you are root or just use sudo):
apt-get install ruby rubygems ruby1.8-dev libgemplugin-ruby libgemplugin-ruby1.8
apt-get install libruby-extras libruby1.8-extras rubygems1.8

Download and extract Redmine latest stable (0.9.3 at the moment)

Comparing the table at the Redmine site, I saw that I needed rails version 2.3.5, so install that through gem.  This is probably where I spent the most time as I kept trying to use the Ubuntu provided packages of rake and rails, but just installing gem and then installing them through that finally worked correctly and that's what I would recommend doing.  Here are the packages to install with gem:
gem install rails -v=2.3.5
gem install rake
gem install mysql
gem install passenger

Now to actually configure Redmine to use the database, here I use MySQL, but it's easy to change. This is also assuming that you installed (extracted) it into /var/www/redmine:
cd /var/www/redmine
cp config/database.yml.example config/database.yml
vi config/database.yml

Here is my configuration for the database (password blanked for obvious reasons, use your own here):

production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: *********
  encoding: utf8

Now to actually create the database, first log into mysql and run these commands (again changing the password to your own):
create database redmine character set utf8;
grant all on redmine.* to 'redmine'@'localhost' identified by '********';

Finally, we are ready to start configuring Redmine itself.  The biggest gotcha here is that rake isn't on the path (at least it wasn't in both of my installs).  The easiest way is to just not worry about it, but you can put it on the path by making a symbolic link in the /usr/bin dir or somewhere if you want.  I just used the full path.  If you can't find the rake binary, try
find / -name "rake"

Once you find it, use this in place of /var/lib/gems/1.8/bin/rake if it is different for you.  Make sure that you are in the Redmine directory (/var/www/redmine for me) again.  The first of the next commands initialize a secret word that the rest of the process needs.  After this default data is loaded and finally the default db data is loaded into the database you defined earlier:
/var/lib/gems/1.8/bin/rake config/initializers/session_store.rb RAILS_ENV=production
/var/lib/gems/1.8/bin/rake redmine:load_default_data RAILS_ENV=production
/var/lib/gems/1.8/bin/rake db:migrate RAILS_ENV=production

Next we move on to configuring passenger, which is an apache2 module that will run Ruby-on-Rails sites inside of virtual hosts or wherever you would like to put them.  We will need to find the directory it was installed to first, then compile it, and finally enable it in apache itself.  It should be in the same relative location as rake; for me it was in /var/lib/gems/1.8/gems/passenger-2.2.11/
cd /var/lib/gems/1.8/gems/passenger-2.2.11/
bin/passenger-install-apache2-module

Make sure that everything compiles fine, and now we will need to activate it in apache itself.  Go to the mods-available directory in the apache2 folder (/etc/apache2/mods-available), and create a file called passenger.load with the following line (note this may change if your path to passenger was different):
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so

Next create another file called passenger.conf and add these lines to it changing for your own path if needed:
PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/bin/ruby1.8

Finally enable the module in apache2:
a2enmod passenger

The next step is to create either a virtual host or use symbolic links and such to create a new directory entry in an existing site for Redmine (which I did).  I will post the directory directive here, but it should be trivial to incorporate this into a new virtual host:
<Directory "/var/www/site_path/redmine">
                Options -Indexes FollowSymLinks
                RailsEnv production
                RailsBaseURI /redmine
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
The thing to get from this is "RailsEnv production", which should match all the commands you've been giving the whole time.  One thing caught me here the second time - no matter which method you use to host it, make sure that the Redmine host/directory is pointing to the public folder in the root redmine folder.

Finally, restart apache:
/etc/init.d/apache2 restart

Browse to the server page and enjoy!  As a final note, the default user/password is admin/admin to get things started.

No comments:

Post a Comment