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/