Installing a Production Pootle 2.5.0 Server on Ubuntu 12.04.3 with MySQL & MemCache

We’re going to install a Production Server configuration of Pootle the ‘Community localization server’ onto a base install of Ubuntu 12.04.3. As part of the base install, you need to have selected the LAMP package option so that MySQL database server installed.

Initial Configuration

Firstly, since we’re going to be doing a lot of package installation, it’s best to move into SuperUser mode:

$ sudo -s

Now let’s start installing all the packages we’re going to need:

root$ apt-get install python-dev libxml2-dev libxslt1-dev

We need Aeidon to support subtitle formats, Levenshtein for speed-up when updating against templates, Xapian for fast text indeing and Zip to provide fast (un)compression of file archives:

root$ apt-get install python-aeidon python-levenshtein libxapian-dev xapian-tools zip

We’re going to install Pootle using Python PIP, but we need to install it first.

root $ apt-get install python-pip

To ensure we do things properly, we’re also going to configure a separate Python environment using VIRTUALENV. Again, we need to install it first:

root$ pip install virtualenv

Now create a virtual environment on your location of choice by issuing the virtualenv command:

root$ virtualenv /var/www/pootle/env/

This will copy the system’s default Python interpreter into your environment. For activating the virtual environment you must run the activate script:

root$ source /var/www/pootle/env/bin/activate

Every time you activate this virtual environment, the Python interpreter will know where to look for libraries. Also notice the environment name will be prepended to the shell prompt.

Install Pootle

Now we’ll download, configure & install Pootle:

This will fetch and install the minimum set of required dependencies as well.

(env)root$ pip install pootle==2.5.0

Note we’re forcing pip to install version 2.5.0. If this is omitted, I’ve noticed that it seems to default to installing 2.5.0-rc1.

If you’ve followed things so far, pip should download pootle and it’s dependancies and be able to build any required libraries without any further input.

At this point, you should be able to type the following:

(env)root$ pootle --version

Which should generate the following information:

Pootle 2.5.0
Translate Toolkit 1.10.0
Django 1.4.8

If everything is okay, we can go ahead & configure our Pootle instance.

Initialise our Pootle Instance

Get Pootle to initialise itself & generate a configuration file:

(env)root$ pootle init

By default this file will be created at ~/.pootle/pootle.conf

You’ll need to make a number of edits to this file during the installation. One we need to make now is to allow the Pootle server to be accessed by any host.

(env)root$ nano ~/.pootle/pootle.conf

 Change the ALLOWED_HOSTS setting to:

ALLOWED_HOSTS = ['*']

By default, DJango limits host logins to the ‘localhost’ only, changing this allows logins from anywhere.

MySQL Database Configuration

We’re going to use MySQL as our backend database. For the purposes of this guide, I’ll assume you’ve already installed and configured your MySQL server.

Install the necessary packages:

(env)root$ apt-get install python-mysqldb libmysqlclient-dev
(env)root$ pip install mysql-python

Now login to your MySQL server to create our database for Pootle:

(env)root$ mysql -u (your mysql username) -p

Enter the following to create the database in your MySQL server:

CREATE DATABASE pootle CHARACTER SET = ‘utf8′;
GRANT ALL PRIVILEGES ON pootle.* TO pootle@localhost IDENTIFIED BY ‘pootlepassword’;
FLUSH PRIVILEGES;

Edit the Pootle configuration file to reflect our database backend:

(env)root$ nano ~/.pootle/pootle.conf

Change the DATABASES section to the following:

# Database backend settings
DATABASES = {
'default': {
# Replace 'sqlite3' with 'postgresql_psycopg2', 'mysql' or 'oracle'.
'ENGINE': 'django.db.backends.mysql',
# Database name or path to database file if using sqlite3.
'NAME': 'pootle',
# Not used with sqlite3.
'USER': 'pootle',
# Not used with sqlite3.
'PASSWORD': 'pootlepassword',
# Set to empty string for localhost. Not used with sqlite3.
'HOST': '',
# Set to empty string for default. Not used with sqlite3.
'PORT': '',
}
}

MemCache Configuration

We’re going to use MemCache to speed things up:

(env)root$ apt-get install memcached
(env)root$ pip install python-memcached

Edit the Pootle configuration file to reflect our cache backend:

(env)root$ nano ~/.pootle/pootle.conf

Change the CACHES section to the following:

CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    'LOCATION': '127.0.0.1:11211'
    }
}

Running Pootle

We need to get Pootle to initialise it’s database & assets:

(env)root$ pootle syncdb
(env)root$ pootle initdb

and also it’s assets:

(env)root$ pootle collectstatic --noinput
(env)root$ pootle assets build

Apache 2 Configuration

We need to ensure we’ve got the mod_wsgi Apache2 module installed:

(env)root$ apt-get install libapache2-mod-wsgi

Create the site definition for Apache:

 

(env)root$ nano /etc/apache2/sites-enabled/pootle

Type the following into the editor:

WSGIRestrictEmbedded On
WSGIPythonOptimize 1

<VirtualHost *:80>
    # Domain for the Pootle server. Use 'localhost' for local deployments.
    #
    # If you want to deploy on example.com/your-pootle/ rather than in
    # my-pootle.example.com/ you will have to do the following changes to
    # this sample Apache configuration:
    #
    # - Change the ServerName directive to:
    #   ServerName example.com
    # - Change the WSGIScriptAlias directive to (note that /your-pootle must
    #   not end with a slash):
    #   WSGIScriptAlias /your-pootle /var/www/pootle/wsgi.py
    # - Change the Alias and Location directives for 'export', and the Alias
    #   directive for 'assets' to include the '/your-pootle'.
    # - Include the following setting in your custom Pootle settings:
    #   STATIC_URL = '/your-pootle/assets/'
    ServerName my-pootle.example.com

    # Set the 'POOTLE_SETTINGS' environment variable pointing at your custom
    # Pootle settings file.
    #
    # If you don't know which settings to include in this file you can use
    # the file '90-local.conf.sample' as a starting point. This file can be
    # found at '/var/www/pootle/env/lib/python2.7/site-packages/pootle/settings/'.
    #
    # Another way to specify your custom settings is to comment this
    # directive and add a new '90-local.conf' file (by copying the file
    # '90-local.conf.sample' and changing the desired settings) in
    # '/var/www/pootle/env/lib/python2.7/site-packages/pootle/settings/'
    # (default location for a pip-installed Pootle, having Python 2.7).
    #
    # This might require enabling the 'env' module.
    SetEnv POOTLE_SETTINGS /var/www/pootle/your_custom_settings.conf


    # The following two optional lines enable the "daemon mode" which
    # limits the number of processes and therefore also keeps memory use
    # more predictable.
    WSGIDaemonProcess pootle processes=2 threads=3 stack-size=1048576 maximum-requests=500 inactivity-timeout=300 display-name=%{GROUP} python-path=/var/www/pootle/env/lib/python2.7/site-packages
    WSGIProcessGroup pootle

    # Point to the WSGI loader script.
    WSGIScriptAlias / /var/www/pootle/wsgi.py

    # Turn off directory listing by default.
    Options -Indexes

    # Set expiration for some types of files.
    # This might require enabling the 'expires' module.
    ExpiresActive On

    ExpiresByType image/jpg "access plus 2 hours"
    ExpiresByType image/png "access plus 2 hours"

    ExpiresByType text/css "access plus 10 years"
    ExpiresByType application/x-javascript "access plus 10 years"

    # Optimal caching by proxies.
    # This might require enabling the 'headers' module.
    Header set Cache-Control "public"

    # Directly serve static files like css and images, no need to go
    # through mod_wsgi and Django. For high performance consider having a
    # separate server.
    Alias /assets /var/www/pootle/env/lib/python2.7/site-packages/pootle/assets
    <Directory /var/www/pootle/env/lib/python2.7/site-packages/pootle/assets>
        Order deny,allow
        Allow from all
    </Directory>

    # Allow downloading translation files directly.
    # This location must be the same in the Pootle 'PODIRECTORY' setting.
    Alias /export /var/www/pootle/env/lib/python2.7/site-packages/pootle/po
    <Directory /var/www/pootle/env/lib/python2.7/site-packages/pootle/po>
        Order deny,allow
        Allow from all
    </Directory>

    <Location /export>
        # Compress before being sent to the client over the network.
        # This might require enabling the 'deflate' module.
        SetOutputFilter DEFLATE

        # Enable directory listing.
        Options Indexes
    </Location>

</VirtualHost>

In order for this to work we need to enable a couple of Apache2 modules:

(env)root$ a2enmod expires
(env)root$ a2enmod headers

Now we need to create the wsgi runner to launch the Pootle application when we access the site:

(env)root$ nano /var/www/pootle/wsgi.py

Type the following into the editor:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import site
import sys


# You probably will need to change these paths to match your deployment,
# most likely because of the Python version you are using.
ALLDIRS = [
    '/var/www/pootle/env/lib/python2.7/site-packages',
    '/var/www/pootle/env/lib/python2.7/site-packages/pootle/apps',
]

# Remember original sys.path.
prev_sys_path = list(sys.path)

# Add each new site-packages directory.
for directory in ALLDIRS:
    site.addsitedir(directory)

# Reorder sys.path so new directories at the front.
new_sys_path = []

for item in list(sys.path):
    if item not in prev_sys_path:
        new_sys_path.append(item)
        sys.path.remove(item)

sys.path[:0] = new_sys_path

# Set the Pootle settings module as DJANGO_SETTINGS_MODULE.
os.environ['DJANGO_SETTINGS_MODULE'] = 'pootle.settings'

# Set the WSGI application.
def application(environ, start_response):
    """Wrapper for Django's WSGIHandler().

    This allows to get values specified by SetEnv in the Apache
    configuration or interpose other changes to that environment, like
    installing middleware.
    """
    try:
        os.environ['POOTLE_SETTINGS'] = environ['POOTLE_SETTINGS']
    except KeyError:
        pass

    from django.core.wsgi import get_wsgi_application
    _wsgi_application = get_wsgi_application()
    return _wsgi_application(environ, start_response)

We need to copy our configuration file into place:

(env)root$ cp ~/.pootle/pootle.conf /var/www/pootle/your_custom_settings.conf

If you have a default Apache website available, you’ll need to remove it:

(env)root$ mv /etc/apache2/sites-enabled/000-default /etc/apache2/sites-available/

Finally, we need to restart Apache to finalise our configuration:

(env)root$ service apache2 restart

Optional Configuration

If you want assistance when doing some of your translation work, Pootle supports using external translation services such as Apertium (free) or Google translate (paid).

If you have an API key for either of these services, they can be entered into the /var/www/pootle/your_custom_settings.conf file and Pootle will utilise these.

HowTo: RedMine 2.0.0, Passenger & Subversion Repositories in Ubuntu 12.04

This is an update to my earlier installation guide for Redmine 1.1.0.

The new Redmine 2.0.0 release now supports Rails 3.2.3 and that, along with a few other changes, makes the installation route slightly different.

As stated before, I AM NOT a Linux/Ubuntu guru, so any mistakes are of my own making and I’d appreciate any feedback to make the installation better/clearer.

So, with all that said, 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.4.2 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.

For this install, I’m using a fresh install of Ubuntu 12.04 LTS, configured as a LAMP server, so Apache, MySQL & PHP are already installed.
Get into the folder where we’re going to install & configure Redmine from:

cd /usr/share
Now we’re going to download the latest version of Redmine from RubyForge:
sudo wget http://rubyforge.org/frs/download.php/76134/redmine-2.0.0.tar.gz

Unpack the archive:

sudo tar xvfz redmine-2.0.0.tar.gz

And tidy things up a little:

sudo rm redmine-2.0.0.tar.gz
sudo mv redmine-2.0.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 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';

Type exit to leave the MySQL prompt.

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: mysql2
 database: redmine
 host: localhost
 username: redmine
 password: my_password
 encoding: utf8
NOTE: Make sure you change the adapter to mysql2! I spent HOURS trying to debug this issue.
NOTE: Don’t forget to change my_password to a password of your own choosing and that it matches what you configured in the MySQL database.
Firstly install all the required libraries:
sudo apt-get install ruby1.9.3 libmysqlclient-dev
If you’re going to use RMagick (to enable Gantt export to png image), you’ll need to add these libraries:
sudo apt-get install libmagickcore-dev libmagickwand-dev
New to Redmine version 1.4.0 and above is support the Bundler to install all the Ruby Gems needed by Redmine.
Enter the following to install Bundler:
sudo gem install bundler
Change into the redmine directory to run Bundler to install our Gems:
cd redmine
As we’ll only be configuring for MySQL, our Bundler needs to know NOT to include Postgre and SQLite.
sudo bundle install --without development test postgresql sqlite
NOTE: If you’re not going to use ImageMagick then change the line to read:
sudo bundle install --without development test postgresql sqlite rmagick
Configure Redmine:
sudo rake generate_secret_token
sudo RAILS_ENV=production rake db:migrate 
sudo RAILS_ENV=production rake redmine:load_default_data

When the last command completes, it will prompt to choose your language. Type the code for the best match to your country & press Enter.

We now need to configure correct directory permissions:

sudo mkdir public/plugin_assets
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/rails 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

Before we can install the Passenger module, we need some additional software:

sudo apt-get install libcurl4-openssl-dev libssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
Now we are set to install the Passenger module for Apache:
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 /var/lib/gems/1.9.1/gems/passenger-3.0.12/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 /var/lib/gems/1.9.1/gems/passenger-3.0.12
PassengerRuby /usr/bin/ruby1.9.1

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 service apache2 restart

If everything went well, then you should be able to see Redmine in your browser:

http://my_website
Configure Subversion

We need to install the necessary packages before we start:

sudo apt-get install subversion libapache2-svn libapache2-mod-perl2
We need to copy the Perl script from Redmine to somewhere it can be accessed:
sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/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::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

Finally, restart Apache

sudo service 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

http://rails.vandenabeele.com/blog/2011/11/26/installing-ruby-and-rails-with-rvm-on-ubuntu-11-dot-10/

http://stackoverflow.com/questions/9134113/i-cant-run-bundler-keep-getting-error

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😀