Archive

Posts Tagged ‘Ruby on Rails’

How to Remove an Old version of Ruby

November 5th, 2009 No comments

This post just saved me a hours of work, thanks :-)

http://www.d-man.org/news/2009/01/06/91/

It outlines how to remove an old version of ruby and install the version you need.

How to Install Tracks 1.7 on Centos 5.2

April 5th, 2009 No comments

 

Install Ruby on Rails – Use http://www.how-to-linux.com/2008/12/how-to-install-ruby-on-rails-on-centos-52/

Create a database for Tracks

mysql -u root -p

create database tracks;

exit

Download Tracks from http://bsag.bingodisk.com/public/files/tracks-current.zip

Unzip the Tracks archive

unzip tracks-current.zip

Put tracks into /opt

mv tracks-1.7 /opt

Edit /opt/tracks-1.7/config/database.yml

vi /opt/tracks-1.7/config/database.yml

Add you mysql server details

production:

  adapter: mysql

  database: tracks

  hosts: localhost

  username: root

  password: neveruserrootpassword

Change a config in site.yml

vi /opt/tracks-1.7/config/site.yml

Add something unique in the salt parameter.

Add the Tracks data to the database

rake db:migrate RAILS_ENV=production

If you get this error;

no such file to load — mysql

Download ruby-mysql – http://rubyforge.org/frs/?group_id=4550

tar mysql-ruby-2.7.tar.gz

cd mysql-ruby-2.7

ruby extconf.rb –with-mysql-config

make

make install

Now run the server

script/server -e production

Goto http://localhost:3000

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