Install Ruby on Rails and Redmine on DS210+

Aus Joachim Schuster Wiki

Wechseln zu: Navigation, Suche

I mentioned it in my manual for (trying) installing Redmine on a DS106j, the 32MB are to few.

As we got a new DS210+ with 512MB RAM and a 1 GHz CPU there was a new chance to get Redmine up and running - and it works!

Inhaltsverzeichnis

pre-requirements

install Ruby on Rails

As you have ipkg up and running, you can simply use the following command to install ruby:

ipkg install rubygems

Additionally (maybe it is not necessary) install zlib:

ipkg install zlib

Now install Rails in Version 2.3.5 to be fit most Redmine pre-requirements (this step will take ca. 30 Minutes even on the shiny new DS210+ so imagine that on the DS106j):

gem install rails -v 2.3.5

install Redmine

Use phpMyAdmin to create a database redmine and optionally a MySQL-user redmine with the rights to access it.

install ruby-mysql

wget http://github.com/downloads/tmtm/ruby-mysql/ruby-mysql-2.9.3-beta.tar.gz
tar -xzvf ruby-mysql-2.9.3-beta.tar.gz
cd ruby-mysql-2.9.2-beta 
ruby setup.rb

create a folder in /volume1 for the redmine service:

cd /volume1
mkdir rubyapps
cd rubyapps

download redmin (We have used the 0.9.5 because we had some strange errors with the newest 1.0.1 redmine):

wget http://rubyforge.org/frs/download.php/71421/redmine-0.9.5.tar.gz

extract it:

tar -xzvf redmine-0.9.5.tar.gz

create a symbolic link to the folder (for easier access later):

ln -s redmine-0.9.5 redmine

change the rights of the folder to the user redmine:

chown redmine:1000 redmine-0.9.5 -R

configure Redmine

login as user redmine:

su redmine

change to folder config in redmine and create database.yml

cd /volume1/rubyapps/redmine/config
cp database.yml.example database.yml  

edit the database.yml

nano database.yml

change:

production:
adapter: mysql
database: redmine <= created in MySQL
host: localhost
username: redmine <= created in MySQL
password: my_password <= set for the user redmine n MySQL


in folder config run following command:

RAILS_ENV=production rake initializers/session_store.rb

Job done!

start Redmine Service

change to root folder of redmine installation:

cd /volume1/rubyapps/redmine

And start the service:

ruby script/server webrick -e production

You can now use your browser and surf to:

http://synolgyIP:3000

start stop script for automatically start service on boot

create the file S97redmine.sh in /usr/syno/etc.defaults/rc.d/ and make it runnable.

Following content (correct the paths!):

#!/bin/ash
case "$1" in
     start)
     /opt/bin/ruby /volume1/rubyapps/redmine/script/server webrick -d -e production 
     ;;
     stop)
     killall ruby
     ;;
     restart)
     $0 stop
     sleep 1
     $0 start
     ;;
     *)
     echo “usage: $0 { start | stop | restart}” >&2
     exit 1
     ;;
     esac


Make it runnable:

chmod 755 S97redmine.sh

Run Service as a different User than root

You must activate the User home folders in the Synology DiskStation Manager.
Gem tries to modify some user specific files in the hidden folder .gem beneath your home folder.
It seams that the -d Parameter does not work, if you have no .gem folder in your users home.

After you enabled the user home folders, you have a symbolic link

/var/services/homes

to the user folder in

/volume1/homes

This home path /var/service/homes is required by the redmine server script (I think it's the value of the bash variable for the home folder).

If /var isn't readable for other users than root, you have to change the corresponding rights:

chmod 755 /var

will let all users browse the folder. Check access by changing to directory /var/services/homes as a normal user.

Additionally you have to start the service in the /volume1/rubyapps/redmine folder (or anywhere where user redmine has write access). The service will create/modify some files in the folder tmp beneath your current folder. If it's in the rc.d folder, only root has access to.

So add following lines instead of /opt/bin/ruby...

cd /volume1/rubyapps/redmine
/bin/su redmine -c "/opt/bin/ruby /volume1/rubyapps/redmine/script/server webrick -d -e production"


If you start ruby with the -w Parameter

/opt/bin/ruby -w /volume1/rubyapps/redmine/script/server webrick -d -e production

you'll get some useful additional information about the startup of the script.

Persönliche Werkzeuge