Installing Ruby Enterprise Edition + Nginx + Passenger + Rails on Ubuntu 10.04
Author: Sergey Kuznetsov kuznecov.sg@gmail.com, May 2010
License: CC BY-SA (Creative Commons Attribution-ShareAlike)
Updated August 2010: Install ruby-enterprise-1.8.7-2010.02 instead of ruby-enterprise-1.8.7-2010.01.
Updated February 2011: Install ruby-enterprise-1.8.7-2011.01 instead of ruby-enterprise-1.8.7-2010.02.Updated March 2011: Install ruby-enterprise-1.8.7-2011.03 instead of ruby-enterprise-1.8.7-2011.01.
Installing prerequisites:
root@hostname:~# apt-get install build-essential patch zlib1g-dev libssl-dev libreadline5-dev
Ruby Enterprise Edition installation, modification of PATH
variable for all users:
root@hostname:~# wget http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03.tar.gz
root@hostname:~# tar zxf ruby-enterprise-1.8.7-2011.03.tar.gz
root@hostname:~# cd ruby-enterprise-1.8.7-2011.03
root@hostname:~/ruby-enterprise-1.8.7-2011.03# ./installer
root@hostname:~/ruby-enterprise-1.8.7-2011.03# cd ..
root@hostname:~# echo "export PATH=\$PATH:/opt/ruby-enterprise-1.8.7-2011.03/bin" > /etc/profile.d/ruby-ee-path.sh
root@hostname:~# export PATH=$PATH:/opt/ruby-enterprise-1.8.7-2011.03/bin
Gems updating and main gems installation:
root@hostname:~# gem update --system
root@hostname:~# gem update
root@hostname:~# apt-get install libsqlite3-dev
root@hostname:~# gem install sqlite3-ruby
root@hostname:~# apt-get install postgresql-client postgresql-8.4 postgresql-server-dev-8.4
root@hostname:~# gem install pg
root@hostname:~# apt-get install mysql-server mysql-client libmysqlclient16 libmysqlclient16-dev
root@hostname:~# gem install mysql
Additional gems installation (you may not need them):
root@hostname:~# gem install sinatra
root@hostname:~# gem install data_mapper
Compiling and installing latest Nginx+Passenger module:
root@hostname:~# cd /tmp
root@hostname:/tmp# wget http://nginx.org/download/nginx-0.8.54.tar.gz
root@hostname:/tmp# tar zxf nginx-0.8.54.tar.gz
root@hostname:/tmp# passenger-install-nginx-module
[...]
[Select 2 option - for the advanced users]
Where is your Nginx source code located?
Please specify the directory: /tmp/nginx-0.8.54
[...]
[I need to compile including SSL module, so I add an extra argument]
Extra arguments to pass to configure script: --with-http_ssl_module
[...]
Nginx Ubuntu init.d script (you need to create the /etc/init.d/nginx
script and chmod +x /etc/init.d/nginx
after this):
#! /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=/usr/local/sbin:/usr/local/bin:/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|force-reload}" >&2
exit 1
;;
esac
exit 0
If you want to start nginx automatically, you need to update init scripts by following command:
root@hostname:/tmp# update-rc.d nginx defaults