Posts Tagged ‘ CentOS

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

RHEL vs Fedora

In the past I’ve been asked a lot about what the difference is between RHEL and Fedora – a lot of people think that Fedora is just a ‘free’ version of RHEL with pretty much the same features with the only difference being that you have to pay for support with RHEL whereas Fedora is only community supported. Unfortunately there are more differences between Fedora and RHEL than just support. The best way I can describe it is a comparison between a Formula 1 car (Fedora) and a well-cared-for Mercedes road car (RHEL). The F1 car has all the latest gadgets and technology and is on the bleeding edge of design, but unfortunately things can go wrong, and things like the tires wear down and sometimes the car flies off the track after a corner (update). If there’s a design flaw (bug) the chances are they won’t re-design a new car mid-season just to fix it – they’ll rather fix it in the next design.
The F1 car design gets a new release each season with a new paint job and better performing spoilers etc and unfortunately accidents still happen. After a year or so, the old car design is scrapped completely and parts aren’t made specially for it any more (it’s reached End-Of-Life and is no longer supported).

On the other hand however we have the Mercedes road car which has drawn all of the experience of building the engines and parts for the F1 car, but have had the time to mature the technology used in F1, make it extremely resilient and safe and put it all into a stable car. You can be confident driving the road car that nothing will break unexpectedly and that even if it does, you can take it to the garage and they’ll figure out what’s wrong and make it right again (bug fixes). You get air bags (RHCE’s ;) ). You also get the peace of mind knowing that the car has a warranty and will last for a long time to come, and that parts will always be available for it, and that the tyres won’t wear down quickly etc. All because you know the car has been safety tested and engineered to withstand a crash and a break-down.

I think that’s about as far as I can take the analogy – but I’m sure you get the drift :)

Dropbox and CentOS 5

Well, since my last post I’ve been attempting to get Dropbox working on CentOS (since this is my server platform). I have so many potential uses for having dropbox running on my server that I’d probably bore anyone reading this if I listed them. Needless to say, it’d be very useful for me if Dropbox would work.

Rather than run the installation on my live server(s), I decided to do a test install on a Virtual Machine. I fired up VMWare and created a minimal installation of CentOS (and I mean minimal) and after installing VMware tools I installed the GNOME desktop along with the X11 Window Manager. I normally use KDE, but unfortunately Dropbox only currently supports Nautilus and not Konqueror :( .

yum --exclude=nautilus-sendto groupinstall 'X Window System' 'GNOME Desktop Environment'

Now, officially CentOS is not supported by Dropbox, there are no packages for CentOS provided by Dropbox so I thought I’d get the source and see what I could do with it. The package requirements are higher than the CentOS package versions available through traditional channels. I thought I’d have a pop anyway and document how far I got here. The two key problems are that Dropbox require glib2 version to be at least 2.14.0 and libnotify needs to be at least 0.4.4. CentOS 5.2 (current release at time of writing) only has packages for glib2 at 2.12.3-2 and libnotify at 0.4.2-6. I wasn’t about to let that stop my potential enjoyment of Dropbox though, so I installed the other dependencies using yum:

yum install bzip2 wget make gtk+-devel libnotify-devel nautilus-extensions.i386 nautilus-devel.i386 gnome-vfs2-devel compat-glibc-headers.i386 compat-glibc.i386 gnome-desktop-devel.i386

Then I got the latest source from the DropBox download page and untarred it:

wget http://dl.getdropbox.com/u/5143/nautilus-dropbox-packages/0.4.1/nautilus-dropbox-0.4.1.tar.bz2
tar jxf nautilus-dropbox-0.4.1.tar.bz2

Next, I had to alter the configure script to accept our versions of glib2 and libnotify which was just a matter of finding and replacing

GLIB_REQUIRED=2.14.0
LIBNOTIFY_REQUIRED=0.4.4

with

GLIB_REQUIRED=2.12.0
LIBNOTIFY_REQUIRED=0.4.2

Then I ran the

./configure
make
make install

Everything seemed to compile ok. Time to fire up the desktop… GNOME launched ok, but nautilus refuses to load. The problem is revealed when trying to start nautilus from the command line:

[rob@localhost ~]$ nautilus /home/rob
Initializing nautilus-dropbox 0.4.1
nautilus: symbol lookup error: /usr/lib/nautilus/extensions-1.0/libnautilus-dropbox.so: undefined symbol: g_timeout_add_seconds

It looks like Dropbox really does require the specified versions of those packages which is a real shame. So in short, unless anyone comes up with a workaround, or Dropbox release a more compatible version it looks like there’s no awesomeness to be had with Dropbox and CentOS / RHEL :(

Never-the-less the awesomeness still reigns on the Windows platform!