Archive

Archive for the ‘Mongrel’ Category

How To Install Redmine on Centos 5.2 Update

February 1st, 2009 5 comments

This is a combination of all my instructions on how to setup redmine on Centos.  Its still a work in progress so please note any problems in comments.

Install Ruby on Rails

yum install ruby ruby-devel ruby-libs ruby-irb ruby-rdoc ruby-mysql

Download and install ruby gems

wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz

tar xvf rubygems-1.3.1.tgz

cd rubygems-1.3.1

ruby setup.rb

Install Rails

gem install rails

Install Redmine

go to /opt

cd /opt

Get latest source code from http://www.redmine.org

unzip redmineXXXX.zip

Create a Database for Redmine

mysql -u root -p

create database redmine character set utf8;

exit

Configure the Redmine database connection settings

Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for “production” environment.

cp /opt/redmine-0.7.3/config/database.yml.example /opt/redmine-0.7.3/config/database.yml

edit database.yml

production:

adapter: mysql

database: redmine

host: localhost

username: yourusername

password: yourpassword

socket: /var/lib/mysql/mysql.sock

Run the following command in /opt/redmine-0.7.3/

rake db:migrate RAILS_ENV=”production”

If you get this error message: “cannot connect to mysql: No such file or directory – /tmp/mysql.sock”, You forgot to specify the socket location in config/database.yml – see above.

This will create tables and an administrator account.

Run this command to load default data into db.

rake redmine:load_default_data RAILS_ENV=”production”

Test the installation by running WEBrick web server:

ruby script/server -e production

Once WEBrick has started, point your browser to http://localhost:3000/. You should now see the application welcome page.

Use default administrator account to log in:

login: admin

password: admin

You can go to Admin & Settings to modify application settings.

You must install Rmagick as well for the nice Gant charts.

yum install ImageMagick

yum install ImageMagick-devel

gem install rmagick -v 1.15.13 –no-rdoc –no-ri

How to Autocreate SVN repositories with Redmine

Create a repository folder.

mkdir /svn

Change the owner and group to root.apache

chown -R root.apache /svn

Change the permissions

chmod 0750 /svn

Configure subversion to be browsed, goto /etc/httpd/conf.d

vi subversion.conf

Insert the following at the bottom

<Location /svn>

DAV svn

SVNParentPath /svn

SVNListParentPath on

</Location>

If you get ‘Could not open the requested SVN filesystem’ when you try to browse to your repository http://localhost/svn then you have used SVNPath instead of SVNParentPath, just update your subversion.conf and that should fix this issue.  This could also be a permission error related to the file permissions of your svn repository, make sure they are readable by apache.

Run the following command to test that it works

ruby reposman.rb -redmine localhost:3000 -svn-dir /svn -owner apache -url http://localhost/svn/ -verbose

If it does not, and fails with this error

/usr/lib/ruby/1.8/rdoc/ri/ri_options.rb:53: uninitialized constant RI::Paths (NameError)

from /usr/lib/ruby/1.8/rdoc/usage.rb:72:in ‘require’

from /usr/lib/ruby/1.8/rdoc/usage.rb:72

from reposman.rb:59:in ‘require’

from reposman.rb:59

Then you need to edit the reposman.rb file and add require statement require ‘rdoc/ri/ri_paths’ above all the other require statements.

require ‘rdoc/ri/ri_paths’

You need to add this to your crontab

5 * * * * ruby /opt/redmine-0.8.0_RC1/extra/svn/reposman.rb -redmine localhost:3000 -svn-dir /svn -owner apache -url http://localhost/svn/ -verbose >> /var/log/reposman.log

Setup permission for SVN to use apache etc

I found the instructions at http://www.redmine.org/wiki/redmine/Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl did not work for me. I managed to get it working doing the following;

You do not need to but you can set subversion 1.54 by installing the RPMForge repos, follow these instructions – http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

Get the necessary packages

yum install mod_dav_svn mod_perl perl-Apache-DBI perl-Digest-SHA1 perl-DBD-mysql subversion

Copy Redmine.pm from /opt/redmine-0.7.3/extra/svn/Redmine.pm to /usr/lib/perl5/vendor_perl/5.8.8/Apache/

cp /opt/redmine-0.7.3/extra/svn/Redmine.pm /usr/lib/perl5/vendor_perl/5.8.8/Apache/

create a file in /etc/httpd/conf.d/ called redmine.conf and put this in it.

PerlLoadModule Apache::Redmine

<Location /svn>

DAV svn

SVNParentPath “/svn”

AuthType Basic

AuthName redmine

Require valid-user

PerlAccessHandler Apache::Authn::Redmine::access_handler

PerlAuthenHandler Apache::Authn::Redmine::authen_handler

## for mysql

RedmineDSN “DBI:mysql:database=da;host=my.db.server”

## for postgres

# RedmineDSN “DBI:Pg:dbname=databasename;host=my.db.server”

RedmineDbUser “redmine”

RedmineDbPass “password”

</Location>

# a private location in read only mode to allow Redmine browsing

<Location /svn-private>

DAV svn

SVNParentPath “/svn”

Order deny,allow

Deny from all

# only allow reading orders

<Limit GET PROPFIND OPTIONS REPORT>

Allow from redmine.server.ip

</Limit>

</Location>

The error I received from using the Redmine-0.7.X was;

‘Invalid command ‘RedmineDSN’, perhaps misspelled or defined by a module not included in the server configuration’

This is related to not copying Redmine.pm to /usr/lib/perl5/vendor_perl/5.8.8/Apache

Install a Mongrel Front to Apache

Taken from http://www.redmine.org/wiki/redmine/HowTo_run_Redmine_with_a_Mongrel_cluster

Install Mongrel

gem install mongrel mongrel_cluster daemons

Configure the Mongrel Cluster for redmine.

cd /opt/redmine

mongrel_rails cluster::configure -e production -p 8000 -N 3 -c /opt/redmine-0.8.0_RC1 -user apache -group apache

Start the Cluster

mongrel_rails cluster::start

Configure apache as the load balancer

create a new config file in /etc/httpd/conf.d

vi /etc/httpd/conf.d/redmine.conf

paste this into the file

<VirtualHost *>

ServerName your.domain.name

DocumentRoot /opt/redmine-0.8.0_RC1

<Directory “/opt/redmine-0.8.0_RC1/public”>

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

<Proxy balancer://redmine_cluster>

Order allow,deny

Allow from all

BalancerMember http://127.0.0.1:8000

BalancerMember http://127.0.0.1:8001

BalancerMember http://127.0.0.1:8002

</Proxy>

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f

RewriteRule ^/(.*)$ balancer://redmine_cluster%{REQUEST_URI} [P,QSA,L]

</VirtualHost>

And restart apache

service httpd restart

Set up Mongrel as a service and start it automatically on Centos 5.2

December 11th, 2008 No comments

 

From – http://bitsandchaos.wordpress.com/2007/11/18/integrate-mongrel-with-rhel-and-derivatives/

This is tailored for the redmine installation that is descibed on this site.

create a directory

mkdir /etc/mongrel

create a file in that directory

vi /etc/mongrel/mongrel.conf

Put this into the file

# we want three instances, listening on ports 8000, 8001 and 8002

PORTS=”8000 8001 8002″

# the Rails environment (see config/database.yml of your application)

ENVIRONMENT=”production”

# the base name for the log file. Each instance will have a unique log file, as LOGFILE.PORT

LOGFILE=”/opt/redmine-0.8.0_RC1/log/rubyapp.logfile”

# the basename for the pid file. Each instance will have a unique pid file, as PIDFILE.PORT

PIDFILE=”/opt/redmine-0.8.0_RC1/tmp/pids/pidfile”

# the directory containing your RoR application.

ROOTDOCUMENT=”/opt/redmine-0.8.0_RC1/”

# every other extra parameter goes there.

EXTRAPARAMS=”--user apache --group apache”

Create another file

vi /etc/sysconfig/mongrel

Put this into it.

#Path of mongrel_rails

MONGREL=/usr/bin/mongrel_rails

Create another file

vi /etc/init.d/mongrel

Set the permissions

chown root:root /etc/init.d/mongrel

 chmod 755 /etc/init.d/mongrel

add it to chkconfig:

chkconfig -add mongrel

and then set it for automatic starting at appropriate runlevels:

chkconfig –level 345 mongrel on

Put the following in /etc/init.d/mongrel

#!/bin/bash

#

# Mongrel      Startup script for the Mongrel Server

#

# chkconfig: – 84 10

# description: Mongrel is a Ruby on Rails application server

#

# processname: mongrel_rails

# config: /etc/sysconfig/mongrel

# instance config: /etc/mongrel/*.conf

 

# Source function library.

. /etc/rc.d/init.d/functions

 

if [ -f /etc/sysconfig/mongrel ]; then

        . /etc/sysconfig/mongrel

fi

 

# Path to the mongrel_rails server.

mongrel=${MONGREL-/usr/bin/mongrel_rails}

RETVAL=0

 

# For each /etc/mongrel/*.conf file that describes a Ruby on Rails application

# we instantiate the corresponding server instances (one for each port).

# We also cleare the sessions, pids, cache and sockets subdirs.

# Note that you’ll hopefully get a [ OK ] line for each (instance,port) pair.

start() {

      RET=0

      for instancefile in `ls /etc/mongrel/*conf`; do

            echo -n $instancefile;

 

            unset PORTS ENVIRONMENT LOGFILE PIDFILE ROOTDOCUMENT EXTRAPARAMS

            . $instancefile

 

            for INSTANCEPORT in $PORTS; do

                  INSTANCELOG=$LOGFILE.$INSTANCEPORT

                  INSTANCEPID=$PIDFILE.$INSTANCEPORT

                  CMDLINE=”-e $ENVIRONMENT –port $INSTANCEPORT –log $INSTANCELOG –pid $INSTANCEPID $EXTRAPARAMS”

                  if [ -n "$ROOTDOCUMENT" ]; then

                        for SUBDIR in “sessions” “pids” “cache” “sockets”; do

                              rm -f $ROOTDOCUMENT/tmp/$SUBDIR/* 2> /dev/null

                        done

                        (cd $ROOTDOCUMENT; daemon mongrel_rails start -d $CMDLINE)

                        RETVAL=$?

                        if [ "$RETVAL" -ne "0" ]; then

                                RET=1

                        fi

                        echo

                  fi

            done

      done

      return $RET

}

 

# When stopping mongrel_rails we wait a delay of 10 seconds

stop() {

echo -n $”Stopping Mongrel”

killproc -d 10 $mongrel

RETVAL=$?

        # We force remove of PID files (a stopped Mongrel won’t do that for us)

        for instancefile in `ls /etc/mongrel/*conf`; do

                unset PORTS ENVIRONMENT LOGFILE PIDFILE ROOTDOCUMENT EXTRAPARAMS

                . $instancefile

                for INSTANCEPORT in $PORTS; do

                        INSTANCEPID=$PIDFILE.$INSTANCEPORT

                        rm -f $INSTANCEPID 2> /dev/null

                done

        done

        echo

}

 

# See how we were called.

case “$1″ in

  start)

start

;;

  stop)

stop

;;

  status)

        status $mongrel

RETVAL=$?

;;

  restart)

stop

start

;;

  *)

echo $”Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}”

exit 1

esac

 

exit $RETVAL

Use

service mongrel start

service mongrel stop

service mongrel restart

service mongrel status

Categories: Centos 5.2, Mongrel, Redmine Tags: