Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1812903
  • 博文数量: 290
  • 博客积分: 10653
  • 博客等级: 上将
  • 技术积分: 3178
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-24 23:08
文章存档

2013年(6)

2012年(15)

2011年(25)

2010年(86)

2009年(52)

2008年(66)

2007年(40)

分类: 项目管理

2012-11-28 23:20:40

Installing Redmine and Subversion on Ubuntu 10.04

This how-to is designed to help you install Redmine and Subversion on Ubuntu 10.04. It may work on other versions of Ubuntu, and for that matter Linux but I haven’t tested or tried it out.

This guide aims to:

  • Install Subversion with a basic setup
  • Install and setup Ruby on Rail to use Apache via Passenger
  • Install and setup Redmine in a basic configuration

This guide does not:

  • Consider advanced features of Subversion, Redmine, Passenger or Ruby on Rails
  • Look into using other server methods, e.g. mongrel and thin

This is not to say I cannot help you with more advanced configurations, or won’t post about it in the future, I just wanted this guide to help you get up and running with Redmine and subversion as quickly as possible. While this may seem simple, it can be more difficult than first thought, due to Ubuntu’s quirks.

Prerequisites

There are a couple of things that need to be installed before you can begin this guide, effectively you need a LAMP configuration, of which this series of blog posts describes how to install and configure. Now that the server is all setup, lets start by installing subversion

Subversion Installation and Configuration

The main reason for installing Subversion, or SVN for short, is because it is needed to check out some components later. So lets get stuck in and install SVN.

sudo apt-get install subversion libapache2-svn

The next thing to do is configure the user access for subversion this is done by executing

sudo htpasswd -c /etc/subversion/passwd

Where is a new user. All subsequent users are created by doing the following

sudo htpasswd /etc/subversion/passwd
It is important to note if you have the ‘-c’ command it WILL overwrite the existing user file.

Now you need to decide where you want to put your repositories. I suggest you put them all under one root path, for example /home/svn. For each repository you want create a new folder in the svn root folder and then run the following command to turn it into a repository

svnadmin create /home/svn/yourproject

One thing to note is that we are going to use apache to serve the repositories so we need to make the svn root folder and all subsequent child files and folders accessable by apache. This is typically done by using the following command

sudo chown -R www-data:www-data /home/svn/

The final part to getting your repositories to be accessed from a web address, like , is to add the following code to your sites apache config file nomally located in /etc/apache2/sites-available

DAV svn SVNPath /home/svn AuthType Basic AuthName "Your repository name" AuthUserFile /etc/subversion/passwd Require valid-user

The last thing to do is restart apache after saving the file

sudo /etc/init.d/apache2 restart

A couple of caveats. Firstly this only allows you to view and upload to the repository if you have a username and password, and secondly all password details are sent via plain text not via ssl. Configuring subversion to allow gest to view, or upload to, a repository and allowing only ssl access are outside the scope of this document. Check out the  and  website for more advance configurations

Redmine Installation and Configuration

The first thing to note is that the current version of Redmine is 1.0.0RC, although a bugfix version, 1.0.1 is a couple of weeks away. This is important as it requires some specific versions of some applications, which might change in future releases, although I will try to keep this up-to-date.

The second thing to note is that Redmine runs on Ruby on Rails rather than things like php. So we will need to install and setup Ruby on Rails first.

Ruby on Rails Installation

The first thing to do is install ruby, and it’s here that a big quirk of Ubuntu crops up. If you were to install the standard ruby package several key parts for running Redmine are left out so instead the following is executed, to install all required components.

sudo apt-get install ruby-full build-essential

If you want to you can get the installation version by running

ruby –v

You should get something like

ruby 1.8.7p5000 (2009-02-22) [i686-linux]

Importantly if your version of ruby is NOT 1.8.6 or 1.8.7 Redmine will fail to work.

Ruby Gems

In order to install a lot of the required components for Redmine, an install called RubyGems will be installed. Unfortunately the current version of RubyGems in Ubuntu seems not to work properly instead download the latest version from the . For me the latest version is 1.3.7. So lets download RubyGems and extract the files

wget tar xzvf rubygems-1.3.7.tgz

The next thing to do is run the setup file and make sure we can use RubyGems using the gem prefix instead of the gem1.8 prefix. This is accomplished by creating a symbolic link.

sudo ruby rubygems-1.3.7/setup.rb sudo ln –s /usr/bin/gem1.8 /usr/bin/gem

Finally lets just do a bit of housekeeping

rm rubygems-1.3.7.tgz rm -r rubygems-1.3.7Rails

Now we are ready to install Rails, and a couple of other things required for Redmine to work. It is important to add the version number after each application as these are required version for Redmine and current versions are not compatible with Redmine.

sudo gem install rails -v=2.3.5 sudo gem install rack -v=1.0.1 sudo gem install rake -v=0.8.3

Be patient when installing. It may take some time and seem to have crashed, it hasn’t. A way to speed up the install is by adding the “–no-rdoc” command. The documentation is normally the longest part of the install.

MySQL Optimisation

A quick tip that can help performance of a Ruby on Rails application that accesses MySQL is to install the Ruby interface components and the MySQL gem

sudo apt-get install libmysql-ruby libmysqlclient-dev sudo gem install mysqlRedmine Installation

Now you have installed all the prerequisits of Redmine, its time to get down to intalling the actual product, Redmine. You can either download the latest version of Redmine from , and extract it to the location you are hosting your Redmine site, or like me, check it out from the SVN repository. First go to the folder you want to contain Redmine then check it out and update the owner of the new folder

cd /path/to/your/site sudo svn co redmine sudo chown -R www-data:www-data redmine

The final “redmine” part indicates the folder you want to check out Redmine into. Assuming you’ve installed phpmyadmin to administer MySQL, fire it up and open the sql tab and enter the following to create a new database for Redmine. (If you haven’t installed phpmyadmin go to  to ensure you have php installed, and  to install phpmyadmin)

create database redmine character set utf8; create user 'redmine'@'localhost' identified by 'my_password'; grant all privileges on redmine.* to 'redmine'@'localhost';

Now we have the database we need to tell Redmine all about, so we’ll jump into the Redmine folder and configure the database file

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

This will copy the example database file and open it so you can update the file. You need to update the production section so it looks something like this:

production: adapter: mysql database: redmine host: localhost username: redmine password: my_password

Of course, you need to update it with your database details. We now need to create a session store for Redmine and create the database. This is carried out using the following commands

rake generate_session_store RAILS_ENV=production rake db:migrate

Now you have an empty database. This is all well and good but I suggest you load the default data in so that you get an idea of how Redmine works

RAILS_ENV=production rake redmine:load_default_data

So now we’ve pretty much done all the work to test that Redmine does in fact work the permissions and the database. We can test is using the built in WEBrick web server, which is good for testing but not for production. So lets allow it through our firewall and start it up

sudo ufw allow 3000 sudo ruby script/server webrick -e production

Now all you need to is navigate to and you should see Redmine. The default login details are

login:admin password:admin

When you have finished testing press ctrl+c in the shell to stop WEBrick. I would suggest now you’ve finished testing Redmine you close the port for WEBrick

sudo ufw deny 3000Redmine and Apache

So we have Redmine and you will quickly see that if you were to navigate to its path you won’t be able to access it. What we need to do is set up Apache to work with it. There are plenty of ways you can run Ruby on Rails applications. I prefer to use  so that’s what I’ll describe here. So lets install Passenger

sudo gem install passenger

Apache unfortunately has some quirks attached to it which make using Passenger out of the box a bit of a pain, so we need to install some more components

sudo apt-get install apache2-prefork-dev libapr1-dev libaprutil1-dev

Now Apache is ready to interface with Passenger, so lets go ahead and install it

passenger-install-apache2-module

We now need to modify the Apache config files so that Passenger will handle Ruby applications when Apache is pointed to one so execute the following command

sudo nano /etc/apache2/apache2.conf

And add the following to the bottom of the file

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15 PassengerRuby /usr/bin/ruby1.8

Once this is done a reboot of Apache is required to tell it we have updated its configuration.

sudo /etc/init.d/apache2 restart

Redmine is almost at the stage it can be through Apache, just a couple more steps. First open your websites config file

cd /etc/apache2/sites-available sudo nano siteconfig.conf

And modify the file so it looks something like this

DocumentRoot /path/to/redmine/site/public ServerName example.com PassengerPoolIdleTime 0 PassengerEnabled on AllowOverride Options -MultiViews

Or if you access SVN from the same file like this

DocumentRoot /path/to/redmine/site/public ServerName example.com PassengerPoolIdleTime 0 PassengerEnabled on AllowOverride Options -MultiViews DAV svn SVNPath /home/svn AuthType Basic AuthName "Your repository name" AuthUserFile /etc/subversion/passwd Require valid-user

I just want to explain a couple of things. Firstly, PassengerPoolIdleTime set to 0 means that Passenger will never close down its running applications. Secondly, PassengerEnabled on ensures that Apache understands that it need to call passenger for this directory. Finally, for me leaving AllowOverride as it is seems to work for me.

I hope you found this useful. I’m opening this one up to comments so that anyone who has problems can let me know

阅读(1711) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~