HOWTO: Install Subversion, Ruby on Rails and Redmine on CentOS5 (& RHEL5)
[Update 17th Sept 2009]
I’ve just noticed that Redmine version 0.8.5 was released last week, while this HOWTO should still be valid, I have not yet tested it so please report any issues you experience with new installs in the comments and I’ll look into them and amend the HOWTO where necessary
[Updated 3rd June 2009]
So since Assembla changed it’s strategy and forced a monetised service or your once private projects were to become public after some date in February I decided to set up my own subversion repos / web management interface.
I never really used the Assembla service to its full potential however and all I really needed was a basic SVN setup with a webinterface to show the diffs in an eye-friendly format. The only two real choices were Trac and Redmine. I’d already used Trac on Assembla and countless other project sites so I was more drawn to Redmine due to it’s good interface design (imo, the Trac interface looks like it’s stuck together with Lego pieces), its features are more integrated and well, I fancied a change. The only problem was that Redmine runs on Ruby on Rails which I’ve heard very bad things about. So I decided to take a plunge and find out wtf the hassle was all about. It turns out there weren’t any up-to-date, well written and well maintained HOWTO’s out there detailing how to get a functional RoR environment configured on CentOS / RHEL. So I wrote my own (after hitting several brick walls)…
HOWTO: Install Subversion, Ruby on Rails and Redmine on CentOS5 (& RHEL5)
NOTES
- This HOWTO is written for CentOS 5.2 [updates for 5.3 in purple text]
- Replace [FQDN] with either your IP address or the hostname (or FQDN) which you’ll be using to access the interface.
- Replace [user] with the username under whom’s home directory the Subversion repository database will be located. e.g. /home/[user]/svn-repos
- This HOWTO will be using the following variables:
- You already have the “httpd” (apache) package installed
- You will be running apache as the user ‘apache’
- The subversion repository root folder will be under /home/[user]/subversion/
- The vhost’s folder locationg will be /var/www/svn
- The subversion repository to be created will be called ‘example-repo’
Install and set up Subversion
yum install mod_dav_svn subversion
Add the group [user] to the user apache and make the subversion base URL readable and writable…
usermod -aG [user] apache chmod g+x /home/[user] mkdir /home/[user]/subversion chmod g+rwx /home/[user]/subversion chown -R [user]:[user] /home/[user]/subversion
Make the web directory:
mkdir /var/www/svn chown apache.apache /var/www/svn
Put the following into /etc/httpd/conf.d/svn.conf (this is for a sub-repo called ‘example-repo’)
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/www/svn"
ServerName [FQDN]
<Location /example-repo>
DAV svn
SVNPath /home/[user]/subversion/example-repo
AuthType Basic
AuthName "Subversion repo"
AuthUserFile /var/www/passwd
Require valid-user
</Location>
<Directory "/var/www/svn">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
Add an HTTP auth user…
htpasswd -cm /var/www/passwd [user]
Create a proper SVN repository
cd /home/[user]/subversion su [user] -c "svnadmin create example-repo"
Import any SVN repos by doing:
su [user] -c "svnadmin load example-repo < /path/to/repo/dump/file"
Make sure the permissions are correct
chmod g+rwx /home/[user]/subversion chown -R [user].[user] /home/[user]
Install Ruby on Rails
*NOTE: Ruby on Rails installation requires the EPEL yum repository (at time of writing).
su -c 'rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm'
Let’s get Ruby up and running first… [NOTE: not on an SElinux environment cba with that]
yum install httpd httpd-devel apr make gcc-c++ mysql-server mysql ruby ruby-devel ruby-docs ruby-ri \ ruby-libs ruby-mode ruby-tcltk ruby-irb ruby-rdoc fcgi fcgi-devel mod_fcgid rubygems subversion-ruby
Now we’ll install passenger (aka mod_rails)
gem install passenger passenger-install-apache2-module
Create and insert this text into /etc/httpd/conf.d/rails.conf (or alternatively edit the existing svn.conf created when we set up subversion)
NOTE:
- The below configuration is specific to the installation of redmine (hence the DocumentRoot)
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /usr/bin/ruby
NameVirtualHost *:80
<VirtualHost *:80>
ServerName 192.168.10.17
DocumentRoot /var/www/rails/redmine/public
</VirtualHost>
Now on to Redmine itself
Get Redmine 0.8 from http://www.redmine.org/wiki/redmine/Download
cd /usr/src svn co http://redmine.rubyforge.org/svn/branches/0.8-stable redmine-0.8 mkdir /var/www/rails/ cd /var/www/rails/ cp -r /usr/src/redmine-0.8/ redmine/ chown -R apache.apache redmine cd redmine
Create a clean backup of source files
tar czf Redmine0.8-clean.tar.gz .
Initialise mySQL:
service mysqld start
To secure mysql:
mysql_secure_installation
Create a mysql database for redmine…
mysql -u[username] -p
At the prompt enter:
create database redmine character set utf8;
Quit with:
quit
Copy the example database file to the “live” location
cd /var/www/rails/redmine cp config/database.yml.example config/database.yml
Enter the appropriate settings for the [production] section ensuring that host is set to 127.0.0.1
vim /var/www/rails/redmine/config/database.yml
Set up email
cd /var/www/rails/redmine cp config/email.yml.example config/email.yml
Enter the appropriate settings for the [production] section ensuring that “address” is set to the IP address of the SMTP host
vim /var/www/rails/redmine/config/email.yml
Install rails for redmine using gem…
cd /var/www/rails/redmine/app/ gem install -v=2.1.2 rails
Import the redmine database into the live database specified in the above config file
cd /var/www/rails/redmine/app/ rake db:migrate RAILS_ENV="production"
Install default configuration data in database (this is entirely optional, but recommended).
cd /var/www/rails/redmine/app/ rake redmine:load_default_data RAILS_ENV="production"
Bring up the testing webserver, once loaded check your config by browsing to http://[FQDN]:3000
cd /var/www/rails/redmine/ ruby script/server -e production
Make sure your apache config file edits are ok and that the services will start at boot by doing:
service httpd configtest service httpd restart chkconfig httpd on chkconfig mysqld on
[Optional:] Add the following to your crontab which will create a database backup in the /home/[user] directory
/usr/bin/mysqldump -u <user> -p <password> <database> | gzip > /home/[user]/redmine_`date +%y_%m_%d`.gz
Make your subversion server configuration accessible to redmine by doing the following:
mkdir /etc/subversion cp -r /root/.subversion/* /etc/subversion/ vim /var/www/rails/redmine/lib/redmine/scm/adapters/subversion_adapter.rb
Change the line:
SVN_BIN = "svn"
to:
SVN_BIN = "svn --config-dir /etc/subversion"
Then restart apache:
service httpd restart


Thank You Very Much Rob!!
Hi all,
I have succefully set up a Redmine project, but for some reason my configuration doesn’t work with the svn authentication.
PerlLoadModule Apache::Redmine
DAV svn
SVNParentPath “/svn”
AuthType Basic
AuthName svn
Require valid-user
PerlAccessHandler Apache::Authn::Redmine::access_handler
PerlAuthenHandler Apache::Authn::Redmine::authen_handler
RedmineDSN “DBI:mysql:database=dbname;host=localhost”
RedmineDbUser “myusername”
RedmineDbPass “mypass”
It keeps on prompting the login window over and over.
My subversion client shows this to me:
svn: PROPFIND request failed on ‘/svn’
svn: PROPFIND of ‘/svn’ authorization failed (http://mydomain.com)
after the fourth time the login window shows up.
We can successfully login into the redmine project but not browse the svn repository through apache.
What’s wrong with that configuration?
I would appreciate any help
Greetings,
Alessandro
linux Centos 5.2 Redmine 0.8
Alessandro, I gather that you’re attempting to use Redmine as an authentication method as set out in this HOWTO. Personally, I haven’t attempted this method, since I’m using Redmine for simple usage.
Without knowing too much about your individual setup, I gather you’re storing all of your subversion repositories under the root path of /svn, however it looks to me like you’re authenticating a user based on a root path, rather than an individual repository. I don’t know if such a thing is possible within Redmine – if you’re able to view/login to the repository using a browser if you browse to the http:// URL then it’d seem to me to be more a problem with Redmine. Best of luck!
You da man. Thanks for the instruction. I’m noob in Ruby on Rails and I have been trying to install this darn Redmine for quite some time and couldn’t find a good clear documentation until I find your article. Excellent job and keep up the good work. Thank you again..
Excellent HOWTO
I took about 1 hour 30 minutes to install and configure everything, as outlined here. (I used postgresql instead of mysql, and hence had to do some things differently)
PS. Would appreciate if you remove the animated penguins from your blog. They are a CPU hog.
Why is this package needed:
ruby-tcltk
?
It pulls in a few more dependencies which are pretty big!
I tried installing Redmine without it and it seems to be working fine.
Tooo good doc !!!!!! It was very easy to get redmine – svn install on my system with the help of this document. Keep it up the good work
Did you test the performance?
on my server i have big issues.
Call directly on the 3000 port or the proxied url – not useful!
Any idea?
Performance isn’t an issue for my installation at all, in fact it’s really quite fast. If you have a very large repo with a lot of history then I’d imagine it’d take a while to do an initial “scan” into redmine – that said, I have a repo about 1GB in size and have no performance impact.
To be honest you’re better off asking over at the redmine project (redmine.org), look through your logs, watch which process is using resources at the time of the slow-down, just start with the basics and work from that.
@sCHween
Be sure to use fcgi or fastcgi. It runs like a dog without it. I had no luck with fastcgi on centos 5.2. fcgi worked well for me. Just be sure to disable or revise selinux policy. Had a heck of a time with errors related to the socket it creates in the tmp folder until I disabled selinux.
Hi. Thanks for this HOWTO it saved my day (well, probably my week actually).
Just one thing I want to point out. I’m doing this on a x86_64 server and when I ran “passenger-install-apache2-module” I got an error stating: “/usr/bin/ld: cannot find -laprutil-1″.
It turns out that the yum install command that you use installs apr-util-devel as a dependency, but only the i386 version of it.
Doing a “yum install apr-util-devel” installed the 64 bit version and solved this problem for me.
I can recommend installing Ruby Enterprise Edition. The installer compiles Ruby from source and installs the necessary gems. It’s a more efficient Ruby interpreter that the one installed through packages. Together with Phusion Passenger, it outperforms this configuration by far.
I fired up the first command yum install mod_dav_svn I already have subversion version 1.6.6 (r40053) and httpd Server version: Apache/2.2.3.
And so there was the dependency error…
Missing Dependency: subversion = 1.4.2-4.el5_3.1 is needed by package mod_dav_svn-1.4.2-4.el5_3.1.i386 (rhel-i386-client-workstation-5)
I already have a svn repository and a website running on httpd. I want to know that how can I safely install this on RHEL5… Please email me or leave a comment here
Hi,
I followed your tutorial to the letter, and got no big errors. Just a mysql socket that could not be found, which I fixed by creating a symbolic link. But when I try to access redmine through apache, I get a 500 – internal server error (and not the page from redmine, but the apache page). Running the redmine service without apache is fine.
Any thoughts?
Erik-Jan
That sounds like there’s something in your apache config which is wrong or incompatible with the HOWTO perhaps.
What do the logs say in /var/log/httpd/error_log ?
I have configured all the things but when I migrate the database with the command “rake db:migrate RAILS_ENV=”production” ” I got this error.
rake db:migrate RAILS_ENV=”production” –trace
(in /var/www/rails/redmine)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load — mysql
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in `require’
….[output truncated]….
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load’
/usr/bin/rake:19
So when i try this command “gem install mysql” then i got this:-
gem install mysql
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
checking for mysql_ssl_set()… no
checking for rb_str_set_len()… no
checking for rb_thread_start_timer()… no
checking for mysql.h… no
checking for mysql/mysql.h… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/ruby
–with-mysql-config
–without-mysql-config
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for i
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make
Please help me out in this. I’m using Centos 5.3.
It looks like you’re missing some mysql headers / libraries. You will need mysql-libs and/or mysql-libs…
# yum install mysql-libs mysql-devel
# gem install mysql
Let me know how you get on
I tried to get mysql headers / libraries by the command but i could not get it. I’m using these versions of Mysql:
mysql-5.0.77-4.el5_4.1
mysql-server-5.0.77-4.el5_4.1
so i think i may need mysql-libs-5.0.77-4.el5_4.1 but i could not find them anywhere on internet. Please give me link for the same if you have any and Guide me if I need anything else.
Thanks!
Somebody please help me out with this.
I would be very grateful to him.