tags:

For a while, I've been looking for a web-based project management tool to help med keep track of ideas, documents, releases a.s.o. for the projects I'm working on. I prefer to host such tools myself, as I like to keep my files under my control. So I found redmine, which (unlike other web applications I've tried) is running on ruby on rails. Googling a bit made me confident that installing this on my Ubuntu 8.10 server wouldn't be a problem. I was nearly correct..
I ended up running redmine in lighttpd behind Apache2's proxy, which is amazingly fast, by the way.
This howto/guide is written so that I can remember how to set up redmine again, if when required. It s partly based on this guide and partly on the official Apache proxy and redirect documentation.

I installed redmine in /opt/redmine/site/ and placed the lighttpd and apache config files in the /opt/redmine/ folder.
By placing the files like this, I have all configuration in the same folder - easy to backup.

Both the lighttpd and the apache proxy setups are done using name-based virtual hosts, as I have a number of sites and and applications on the server already.

Installing the prerequisites:


sudo apt-get install libmysql-ruby mysql-server subversion apache2 ruby rubygems irb rdoc phpmyadmin rake

In order to satisfy the requirements of redmine 0.8.x, rails is installed using ruby gems. The Ubuntu repositories contains v. 2.1.0 of the rails framwork; redmine requires 2.1.2.
sudo gem install -v2.1.2 rails

Get and unpack current redmine source:


cd /opt/redmine
wget http://rwget http://rubyforge.org/frs/download.php/51747/redmine-0.8.1.tar.gz
tar xzf redmine-0.8.1.tar.gz
mv redmine-0.8.1 site

Database setup:

I use phpmyadmin to create the database, and to separate privileges (I have lot of test/experimental databases), I always create a user with a random password and check Create database with same name, and assign user all privileges. In this case, the username/database is redmine.
Copy the example database config and edit it:

cd /opt/redmine/site
cp config/database.yml.example config/database.yml
nano config/database.yml

Make the production section look something like this:

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

Create the database structure using the ruby 'make' equivalent:

rake db:migrate RAILS_ENV="production"

Populate the database with default data

rake redmine:load_default_data RAILS_ENV="production"

And enable the default document of the site:

cp dispatch.fcgi.example dispatch.fcgi

Now allow the web user (lighttpd runs as www-data) to read and write certain folders:

mkdir tmp 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

At this point, the redmine installation can be tested by running the a WEBrick server like this:

sudo ruby script/server -e production

The default login is admin/admin.

If the server works, it is time to install and configure lighttpd:

sudo apt-get install lighttpd

Edit the lighttpd config to enable ruby, vhost and rewrite modules, to listen on a different port and to use a different root dir. The two latter is to avoid conflicts with apache.

To the server.modules property, add

"mod_simple_vhost",
"mod_rewrite",
"mod_fastcgi"

Change the document root:

server.document-root = "/var/lighttpd/"

Change the listening port:

server.port = 81

Now create the document root:

sudo mkdir /var/lighttpd
sudo chown www-data:www-data /var/lighttpd/

At this point, basic lighttpd configuration is done, and we will now do the redmine specific setup for lighttpd. This is what my /opt/redmine/lighttpd.conf file looks like (except the hostname part):

$HTTP["host"] == "" {
server.document-root = "/opt/redmine/site/public/"
server.indexfiles = ( "dispatch.fcgi" )
server.error-handler-404 = "/dispatch.fcgi"
fastcgi.server = (
".fcgi" => (
"localhost" => (
"bin-path" => "/opt/redmine/site/public/dispatch.fcgi",
"socket" => "/tmp/redmine.socket",
"min-procs" => 1,
"max-procs" => 4,
"idle-timeout" => 120,
"check-local" => "disable",
"bin-environment" => ( "RAILS_ENV" => "production" ),
)
)
)
}

To make the configuration available to lighttpd, create a symlink:

sudo ln -s /opt/redmine/lighttpd.conf /etc/lighttpd/conf-available/10-redmine.conf

To enable the configuration in lighttpd, run:

sudo lighty-enable-mod redmine
sudo /etc/init.d/lighttpd reload

The setup can now be tested by accessing:

http://:81/

The last part of the setup is the apache proxy configuration which allows access to the redmine application on lighttpd running on port 81 through apache running on port 80, thus keeping the complexity of the setup hidden from the outside world.

My /opt/redmine/apache2.conf file looks like (except the hostname part):

Allow from all
Order deny,allow


ServerName

DocumentRoot /opt/redmine/site/public

ProxyPreserveHost On

# Let apache serve the static content
ProxyPass /images !
ProxyPass /stylesheets !
ProxyPass /javascripts !
ProxyPass /favicon.ico !

ProxyPass / http://localhost:81/
ProxyPassReverse / http://localhost:81/


Al above, the the configuration must be made available to the server by creating a symlink:

sudo ln -s /opt/redmine/apache2.conf /etc/apache2/sites-available/redmine

And enabled by running:

sudo a2ensite redmine
sudo /etc/init.d/apache2 reload

The setup is now done, and the redmine site can be reached at:

http:///

At the moment I have two redmine sites with different host names running side-by-side in the same lighttpd instance. Both sites were setup as described above.

Comments

Valuable information and

Valuable information and excellent design you got here! I would like to thank you for sharing your thoughts and time into the stuff you post!! Thumbs up
implant mammaire

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.