ruby 1.9.3 for Debian Squeeze

# From a fresh install of squeeze
apt-get install ruby rubygems # Need ruby to use fpm
gem1.8 install fpm –no-ri –no-rdoc

apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev

wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -zxvf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
rm -rf /tmp/ruby193
time (./configure –prefix=/usr && make && make install DESTDIR=/tmp/ruby193)

/var/lib/gems/1.8/bin/fpm -s dir -t deb -n ruby193 -v 1.9.3-p125 –description “Self-packaged Ruby 1.9.3 patch 125” -C /tmp/ruby193 \
-p ruby193-VERSION_ARCH.deb -d “libstdc++6 (>= 4.4.3)” \
-d “libc6 (>= 2.6)” -d “libffi5 (>= 3.0.4)” -d “libgdbm3 (>= 1.8.3)” \
-d “libncurses5 (>= 5.7)” -d “libreadline6 (>= 6.1)” \
-d “libssl0.9.8 (>= 0.9.8)” -d “zlib1g (>= 1:1.2.2)” \
-d “libyaml-0-2 (>= 0.1.3)” \
usr/bin usr/lib usr/share/man usr/include

# Post installation test
apt-get remove ruby rubygems
apt-get install libffi5 libyaml-0-2
dpkg -i dpkg -i ruby193-1.9.3-p125_amd64.deb
ruby -ropenssl -rzlib -rreadline -ryaml -e “puts :success”

credit:
https://gist.github.com/futuremill/2318876

ryby on rails and gems

หลังจากที่เรา # apt-get install ruby rubygems ไปแล้ว
สิ่งแรกที่ต้องทำเพื่อให้ใช้ gem ได้ คือ

# export PATH="$PATH":/var/lib/gems/1.8/bin
# export PATH

หรือ ไปเพิ่มใน
/etc/profile

จบ

debian squeeze + redmine + nginx phusion passenger

SYSTEM

  • Debian squeeze
  • Ruby 1.8.7
  • Rails 2.3.5
  • Rack 1.0.1
  • Redmine 1.1.2

How-to

# aptitude install build-essential ruby1.8 ruby1.8-dev irb1.8 rdoc1.8 zlib1g-dev libruby libssl-dev libpq-dev subversion rubygems libcurl4-openssl-dev rake libmysqlclient-dev librmagick-ruby

# ruby1.8 -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]

# gem -v
1.3.7

# gem install -v=1.0.1 rack
# gem install fastthread
# gem install -v=2.3.5 rails
# gem install -v=0.4.2 i18n
# gem install mysql

# ln -s /usr/bin/ruby1.8 /usr/bin/ruby
# ln -s /usr/bin/irb1.8 /usr/bin/irb

# cd /usr/src

# wget http://rubyforge.org/frs/download.php/74605/passenger-3.0.6.tar.gz
# tar xvzf passenger-3.0.6.tar.gz
# cd passenger-3.0.6/bin
# ./passenger-install-nginx-module

Press Enter
Press 1
Press Enter

# nano /etc/init.d/nginx

#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
PATH=/opt/nginx/sbin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/nginx/sbin/nginx
NAME=nginx
DESC=nginx
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi
set -e
case “$1” in
start)
echo -n “Starting $DESC: ”
start-stop-daemon –start –quiet –pidfile /opt/nginx/logs/$NAME.pid \
–exec $DAEMON — $DAEMON_OPTS
echo “$NAME.”
;;
stop)
echo -n “Stopping $DESC: ”
start-stop-daemon –stop –quiet –pidfile /opt/nginx/logs/$NAME.pid \
–exec $DAEMON
echo “$NAME.”
;;
restart|force-reload)
echo -n “Restarting $DESC: ”
start-stop-daemon –stop –quiet –pidfile \
/opt/nginx/logs/$NAME.pid –exec $DAEMON
sleep 1
start-stop-daemon –start –quiet –pidfile \
/opt/nginx/logs/$NAME.pid –exec $DAEMON — $DAEMON_OPTS
echo “$NAME.”
;;
reload)
echo -n “Reloading $DESC configuration:”
start-stop-daemon –stop –signal HUP –quiet –pidfile /opt/nginx/logs/$NAME.pid \
–exec $DAEMON
echo “$NAME.”
;;
*)
N=/etc/init.d/$NAME
echo “Usage: $N {start|stop|restart|reload|force-reload}” >&2
exit 1
;;
esac
exit 0

# chmod +x /etc/init.d/nginx
# /usr/sbin/update-rc.d -f nginx defaults

# cd /usr/src
# wget http://rubyforge.org/frs/download.php/74419/redmine-1.1.2.tar.gz
# tar xvzf redmine-1.1.2.tar.gz
# cd redmine-1.1.2

# mysql -u root -p
Enter password:

mysql> create database redmine character set utf8;
mysql> create user ‘redmine’@’localhost’ identified by ‘my_password’;
mysql> grant all privileges on redmine.* to ‘redmine’@’localhost’;

# cp /usr/src/redmine-1.1.2/config/database.yml.example /usr/src/redmine-1.1.2/config/database.yml

# nano database.yml

production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: my_password
encoding: utf8

####### SECURITY #####

# adduser redmine

# cd /usr/src/redmine-1.1.2/

# chown -R redmine:redmine *

# chmod -R 755 files log tmp public/plugin_assets

 

DEPLOY

# rake generate_session_store
# RAILS_ENV=production rake db:migrate
# RAILS_ENV=production rake redmine:load_default_data

# nano /opt/nginx/conf/nginx.conf

user redmine;

….

location / {
root   /usr/src/redmine-1.1.2/public;
index index.html index.htm;
passenger_enabled on;
}

……

server_name sourcode.net;

# /etc/init.d/nginx start

 

Mail

# cd /usr/src/redmine-1.1.2
# cp config/email.yml.example config/email.yml
# nano email.yml

production:
delivery_method: :smtp
smtp_settings:
tls: true
address: “smtp.gmail.com”
port: 587
domain: “example.com”
authentication: :plain
user_name: “[email protected]
password: password

credit :
http://wiki.nginx.org/RedHatNginxInitScript
http://articles.slicehost.com/2008/5/13/ubuntu-hardy-adding-an-nginx-init-script
https://apps.education.ucsb.edu/w/index.php?title=Redmine/setup&oldid=7943
http://www.ryannagle.net/2010/10/24/how-to-redmine-and-gitosis-with-nginx-passenger-and-ubuntu-part-3/
http://www.minoraddition.com/2010/12/10/redmine-installation-on-ubuntu-10-04/
http://wiki.huihoo.com/wiki/Redmine
http://www.kelvinwong.ca/2010/04/28/sending-redmine-mail-via-google-apps-hosted-gmail/