This covers setting up a Ubuntu 10.10 box to run rails 3 on production. Please notice it only focus on installing and setting up things mentioned in the title. However there are other things that you should configure and setup when deploying a application to production (like ntpd for example).
We will need git before we can get started.
sudo apt-get install git
Install rvm according to the official guide.
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
to your .bashrc.
Once you edit your bashrc file execute the following to load rvm without logging out and back in
Just to be safe check wether rvm is a function, which is what it should be.
type rvm | head -n1
Install ruby 1.9.2
See what you get out of rvm notes. you will need to install some stuff before you can compile ruby.
aptitude install build-essential bison openssl libreadline5 libreadline5-dev curl git-core zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libmysqlclient-dev
The above packages covers some common stuff. It should be enough to get you started. However depending on what gems you want to install you might need to install additional dependencies.
rvm install 1.9.2
Set 1.9.2 as the default
rvm use 1.9.2 --default
Install passenger as instructed in rvm documentation http://rvm.beginrescueend.com/integration/passenger/
rvm 1.9.2 --passenger
gem install passenger
Let passenger downland and install nginx for you.
Modify /opt/nginx/conf/nginx.conf (thats the default location).
‘For Nginx users, replace the passenger_ruby line with:’
Add a block like this to host your RoR site
listen 80; #the server will be running on this port
root /home/deployer/your_rails_project/public; # <--- be sure to point to 'public'!
Nginx init script
git clone git://github.com/jnstq/rails-nginx-passenger-ubuntu.git
sudo mv rails-nginx-passenger-ubuntu/nginx/nginx /etc/init.d/nginx
sudo chown root:root /etc/init.d/nginx
More information on http://wiki.nginx.org/Nginx-init-ubuntu
sudo apt-get install mysql-client mysql-server
Get the source for your rails app. unzip it in your home folder (or where ever you want to. But be sure to edit the nginx config as appropriate).
rake db:setup RAILS_ENV=production
sudo /etc/init.d/nginx restart