Posts Tagged ‘ Red Hat

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

Dropbox + eXtplorer: A better web interface

Ok, so I found myself online at a workstation without admin access the other day and needed desperately to edit a file on my Dropbox account, it was just a plain text file and the edit was only small, so I set about finding a way of doing it, and came up with this as a temporary solution until Dropbox have a fully functional, released API…

preview image

P.S. The error was actually caused by a non-standard character in the filename (+). I’ll be filing a bug with eXtplorer for that :)

Documentation (Wiki) can also be found here.

NOTE: Replace [user] with the username under which the Dropbox folder is located.
NOTE: Replace [FQDN] with either your IP address or the hostname (or FQDN) which you’ll be using to access the interface.

NOTE: This HOWTO assumes that you will be running apache as the user ‘apache’ and that you have already set up your Dropbox account syncing to your /home/[user]/Dropbox folder

To get Dropbox running with apache and extplorer you need to get the following packages:

yum install php httpd

Make the VirtualHost director and get permissions / groups correct:

mkdir /var/www/dropbox
chown apache:apache /var/www/dropbox
usermod -aG [user] apache
usermod -aG apache [user]

Now create and populate an apache virtualhost config file:

vim /etc/httpd/conf.d/dropbox.conf

Populate it with the following text:

NameVirtualHost *:80
    <VirtualHost *:80>
        DocumentRoot "/var/www/dropbox"
        ServerName [FQDN]
        <Directory "/var/www/dropbox">
            allow from all
            Options +Indexes
            AuthType Basic
            AuthName "Dropbox"
            AuthUserFile /var/www/passwd
            Require valid-user
        </Directory>
    </VirtualHost>

Now add a username / password to access your interface via HTTP auth:

htpasswd -cm /var/www/passwd yourusername
chown apache.apache /var/www/passwd

Make sure that apache has full group access to your Dropbox folder.

chmod g+x /home/[user]
chmod g+rw /home/[user]/Dropbox
find /home/[user]/Dropbox -type d -exec chmod g+x {} ;

Download the latest version of eXtplorer from http://extplorer.sourceforge.net/

cd /var/www/dropbox
wget http://heanet.dl.sourceforge.net/sourceforge/extplorer/eXtplorer_2.0.1.zip
unzip eXtplorer*.zip

Check we haven’t made any mistakes and set the services up:

service httpd configtest
service httpd restart
chkconfig httpd on

You can now log into http://[FQDN] using a browser and the default credentials (admin/admin) and set up your user, pointing the user’s “Home directory:” at /home/[user]Dropbox. Once you have set up your user you have the choice to remove the HTTP authentication which we included in the VirtualHost configuration above. Simply comment out (or delete) the following lines from your /etc/httpd/conf.d/dropbox.conf file:

AuthType Basic
AuthName "Dropbox"
AuthUserFile /var/www/passwd
Require valid-user

That’s it, you’re done!

Songbird sings

So, as I wrote in my last entry I installed Fedora 10 on my main desktop earlier in the week and I have to say, I can really see it staying there. The reasons behind my switch over from Windows are too numerous to detail – predominantly Fedora 10 will be used as the bedrock from which RHEL 6 will be carved, moulded and created and I’ve been stuck in RHEL 5 land for a long time without keeping up with the changes that have been going on in the world of Fedora. The past few Fedora releases have been a little shakey (imo) however Fedora 10 got some special love with regard to bug tracking and resolution. And it shows with reviews coming in from left right and centre praising the release.

The main reason I can see myself sticking with linux this time around is due to the fact that there are now real, viable alternative apps for the “killer” apps which I use on a Windows desktop – the best example of this (as you’ve probably guessed already from the title) is Songbird. This is the killer app for me when it comes to music management on linux. As much as I hate Apple I have to admit, I do use iTunes on Windows to organise all my music. The last time I tried Fedora 9 I gave Songbird a spin, which back then was still in ‘beta’, i.e. pre-version 1.

songbird

As you can see Songbird v1 is very much like iTunes, from a layout perspective, however it far far excels, as it’s based on the Mozilla platform, it gains from the inherent web-based functionality which comes with including a web page rendering engine. The result is a completely integrated audio application. The best function (imo) is the ability for artist info to be displayed in the window, along with youtube videos, news and photos. Also Songbird takes the best from Firefox in that the application is highly extensible – for example the album art carosel you see at the top of the window is an extension, you can either choose to install it, or not. Customisation is key, and Songbird use it very very effectively. Songbird has all the functionality of iTunes and then some. I should probably add that I don’t have an iPod and don’t use Songbird to sync an iPod, however there is an extension available which will do that very thing. For more info you might want to read their version 1 release blog post which details the major features / improvements made recently.

Being cross-platform, I’m 100% certain that I will not be switching back to iTunes, since I’ll be able to simply port everything between OS’s. Sterling work Songbird – keep up the awesomeness!