HowTo: RedMine with Subversion in Ubuntu 10.10

The following instructions have been cobbled together from various sources (plus my own random thoughts) and has FINALLY got me a working Redmine installation under Ubuntu 10.10.

I’m far from a Linux/Ubuntu guru so I’d welcome any input/suggestions/corrections to make it better and to correct any mistakes.

Here goes:

I know that Redmine can be installed as a package in Ubuntu, but it doesn’t appear to be the latest version (1.1.0 at the time of writing). So I’m taking the longer route to get it working, as I couldn’t get it to configure the way I want. It does have the advantage that I’m using the very latest version straight from RubyForge.

Firstly install all the required libraries:

sudo apt-get install ruby ruby1.8-dev libgemplugin-ruby libgemplugin-ruby1.8  mysql-server apache2-mpm-prefork wget libruby-extras libruby1.8-extras rails subversion rake apache2-prefork-dev libapache-dbi-perl libapache2-mod-perl2 libdigest-sha1-perl libapache2-svn libmysqlclient15-dev build-essential libcurl4-openssl-dev cron

Now create the database:

sudo mysql -u root -p

This will prompt you for the password for the ‘root’ MySql account you created when you installed MySql.

The prompt will change to:

mysql>

Now enter the following, line by line:

CREATE DATABASE redmine character SET utf8;

CREATE user 'redmine'@'localhost' IDENTIFIED BY 'my_password';

GRANT ALL privileges ON redmine.* TO 'redmine'@'localhost';

Now we’re going to download the latest version of Redmine from RubyForge:

cd /usr/share

sudo wget http://rubyforge.org/frs/download.php/73900/redmine-1.1.0.tar.gz

Unpack the archive:

sudo tar xvfz redmine-1.1.0.tar.gz

And tidy things up a little:

sudo rm redmine-1.1.0.tar.gz
sudo mv redmine-1.1.0 redmine

We also need to adjust some of the ownership of the folders

sudo chown -R root:root /usr/share/redmine

However, we need to make sure that a particular file is set to www-data as owner. This is because Passenger runs as the user that owns this file.

sudo chown www-data /usr/share/redmine/config/environment.rb

We'll create a symbolic link from the main website home back to our actual Redmine application directory:

sudo ln -s /usr/share/redmine/public /var/www/redmine

Now configure the database:

sudo cp redmine/config/database.yml.example redmine/config/database.yml

Run nano or your favourite editor and edit it to the following:

sudo nano redmine/config/database.yml
production:
    adapter: mysql
    database: redmine
    host: localhost
    username: redmine
    password: my_password
    encoding: utf8

Install RubyGem:

sudo wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
sudo tar xvfz rubygems-1.3.7.tgz
sudo rm rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo ruby setup.rb

Install Rails + Rack: (note the version numbers are IMPORTANT, Redmine is VERY picky over which versions it will & won't run with!)

sudo gem install rails -v=2.3.5
sudo gem install rack -v=1.0.1
sudo gem install mysql
sudo gem install i18n -v=0.4.2

Configure Redmine:

cd /usr/share/redmine
sudo rake generate_session_store
sudo RAILS_ENV=production rake db:migrate
sudo RAILS_ENV=production rake redmine:load_default_data
sudo chown -R www-data:www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets

Test Redmine:

sudo ruby script/server webrick -e production

If you enter your webaddress:http://my_website:3000 you should see the Redmine homepage.

If all is well at this point, we can now configure Passenger to make sure it launches when Apache runs.

Install & Configure Passenger:

sudo gem install passenger
sudo passenger-install-apache2-module

Passenger will run & compile the source code into the module for Apache.

Now use nano or your favourite editor to create the loader:

sudo nano /etc/apache2/mods-available/passenger.load
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/apache2/mod_passenger.so

Make a link to make the module enabled:

sudo ln -s /etc/apache2/mods-available/passenger.load /etc/apache2/mods-enabled/passenger.load

Now create a configuration file for Passenger:

sudo nano /etc/apache2/mods-available/passenger.conf
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.2
PassengerRuby /usr/bin/ruby1.8

Now configure Apache for our new site:

sudo nano /etc/apache2/sites-available/mysite
<VirtualHost *:80>
    ServerName my_domain.com
    DocumentRoot /var/www/redmine
    ServerAdmin user@example.com
    LogLevel warn
    ErrorLog /var/log/apache2/redmine_error
    CustomLog /var/log/apache2/redmine_access combined
    <Directory /var/www/redmine>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
        RailsBaseURI /redmine
        PassengerResolveSymlinksInDocumentRoot on
    </Directory>
</VirtualHost>

We also need to tell Apache how to configure Passenger:

sudo nano /etc/apache2/apache2.conf

Add the following line at the end of the file:

Include /etc/apache2/mods-available/passenger.conf

Finally, enable the site:

sudo ln -s /etc/apache2/sites-available/mysite /etc/apache2/sites-enabled/mysite

Remove the default site:

sudo rm /etc/apache2/sites-enabled/000-default

Make sure the Passenger module is enabled:

sudo a2enmod passenger

And, restart Apache:

sudo /etc/init.d/apache2 restart

Configure Subversion

We need to copy the Perl script from Redmine to somewhere it can be accessed:

sudo mkdir /usr/lib/perl5/Apache/Authn

sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Authn/Redmine.pm

Create the site description for our Subversion HTTP access:

sudo nano /etc/apache2/sites-available/svn

Enter the following details:

# /svn location for users
PerlLoadModule Apache::Authn::Redmine
<Location /svn>
    DAV svn
    SVNParentPath "/var/svn"
    Order deny,allow
    Deny from all
    Satisfy any

    PerlAccessHandler Apache::Authn::Redmine::access_handler
    PerlAuthenHandler Apache::Authn::Redmine::authen_handler
    AuthType Basic
    AuthName "Redmine SVN Repository"

    #read-only access
    <Limit GET PROPFIND OPTIONS REPORT>
        Require valid-user
        Allow from my_domain.com
        Allow from localhost
        Satisfy any
    </Limit>
    # write access
    <LimitExcept GET PROPFIND OPTIONS REPORT>
        Require valid-user
    </LimitExcept>

    ## Mysql-Settings
    RedmineDSN "DBI:mysql:database=redmine;host=localhost"
    RedmineDbUser "redmine"
    RedmineDbPass "my_password"
</Location>

Now setup our repository directory:

sudo mkdir -p /var/svn
sudo chown -R www-data:www-data /var/svn
sudo chmod 0750 /var/svn

Now you need to log into Redmine, then select Administration->Settings->Repositories.

Tick the 'Enable WS for repository management' option and then click 'Generate a key'. Remember to click 'Save' to store all the settings.

Now run the following code, entering the data that is correct for your site & key:

ruby /usr/share/redmine/extra/svn/reposman.rb --redmine my_domain.com --svn-dir /var/svn --owner www-data --url http://my_domain.com/svn --verbose --key=my_api_key

This should query your Redmine installation and attempt to create a project directory under the repository root you specified. As this isn't being run as root this will fail, but that's fine.

Now set this up so it'll automatically check for any new projects & create any necessary repositories:

sudo crontab -e

Add the following at the end:

*/10 * * * * ruby /usr/share/redmine/extra/svn/reposman.rb --redmine my_domain.com --svn-dir /var/svn --owner www-data --url http://my_domain.com/svn --verbose --key=my_api_key

Now enable the site:

sudo ln -s /etc/apache2/sites-available/svn /etc/apache2/sites-enabled/svn

Installing RMagick

sudo apt-get install imagemagick libmagick9-dev
sudo gem install rmagick

Finally, restart Apache

sudo /etc/init.d/apache2 restart

And that's all...finally! 🙂

References:

http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_Ubuntu

http://www.redmine.org/projects/redmine/wiki/Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl

http://www.modrails.com/install.html

http://lordsauron.wordpress.com/2008/06/18/zero-to-redmine-in-22-steps/

https://help.ubuntu.com/community/CronHowto

Quick reboot into Windows

If you use Bootcamp then you’ve probably wondered if there’s an equivalent to the excellent Windows Taskbar utility that quickly allows you to reboot to Mac OS X. Well wonder no more as BootChamp is exactly the thing you’re looking for.

Install the little app and reboot your Mac. Upon restarting, you’ll find a little icon on your menu bar that allows you to ‘Restart into Windows’. The first time you do it, it’ll ask you for authorisation, but thereafter, it’s a single click operation – nice n’ easy!

Further information:

Bootchamp (MacUpdate)
Bootchamp (author’s site)

Create a shortcut to your Hyper V virtual machines

If you’re like me, you access your Hyper V server through Remote Desktop, and it’s a bloody pain having to drill down through the Server Manager to get to the Hyper V options.

This quick little script will allow you to launch your VMs from a shortcut on your desktop or anywhere else:

Right click on your desktop and select New -> Shortcut

In the ‘Type the location of the item:’ box, enter the following:

"c:\program files\hyper-v\vmconnect.exe" SERVER VMNAME

SERVER is the name of the Hyper V server
VMNAME is the full name of the Virtual Machine

Click OK and you’re good to go!

NB: This technique will apparently only work if your VM isn’t clustered, another technique is listed in the link for those situations.

Further Reading:
http://social.technet.microsoft.com/Forums/en-US/virtualmachingmgrhyperv/thread/08224516-1f90-4822-b270-cfc8efd89591

Why a blog?

Well here it is…my first blog entry!

You may ask why I’m bothering with a blog in the first place. A fair question actually.

I’ve not joined the chattering masses in the past as I really didn’t have anything I felt was worthwhile saying.  While it’s arguably true that given an infinite time-span an infinite number of monkeys could eventually produce the works of Shakespeare, the output before that significant event is likely to be of a higher quality than most of the writings on the ‘net.

However as time has passed, I’ve come to the opinion that the blog is as good an archive of my random thoughts & discoveries as any other medium. The archive is as much for my own benefit as yours – whoever you may be!

Whilst the slant of this blog is mostly going to be of a computer nature, it’s also likely to touch on the other subjects close to my heart – my work in retail, my current transition from PC user to Mac user, the trials of being a Scotland rugby fan, mountain biking, attempting to manage my weight & fitness as I head rapidly towards 40!

If anything in here prompts you to make a comment feel free to do so…it’d be nice to know I’m not just talking to myself 😀