Rails 3 on Apache on Ubuntu 10.04
So I was investigating how to run a rails app on my VPS. I needed to use several sources to get little bit's working, so here's the combined instructions. Note that I assume you're starting with a working apache installation.
On The Server (Once)
- Create a user for the passenger software:
- sudo adduser passenger
- sudo usermod -G passenger,www-data,sudo passenger
- Initial setup of passenger user and installation of RVM and gems
- su - passenger
- add this to the bottom of .bashrc
- nano -w ~/.bashrc
- [[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
- ctrl-o to save and ctrl-x to exit
- exit
- su - passenger
- sudo apt-get install openssl curl git-core subversion autoconf build-essential bison zlib1g zlib1g-dev libssl-dev libxml2-dev libreadline5 libreadline-dev libreadline6-dev libsqlite3-0 libsqlite3-dev sqlite3
- bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
- rvm install 1.9.2
- rvm use --default 1.9.2
- rvm 1.9.2 --passenger
- gem install passenger
- rvmsudo /home/passenger/.rvm/gems/ruby-1.9.2-p0/bin/passenger-install-apache2-module
- sudo apt-get install apache2-prefork-dev libapr1-dev libaprutil1-dev
- exit
- Remove user from sudo group
- sudo usermod -G passenger,www-data passenger
- Configure apache
- create /etc/apache2/mods-availible/passenger-rvm.load to contai
LoadModule passenger_module /home/passenger/.rvm/gems/ruby-1.9.2-p0/gems/passenger-2.2.15/ext/apache2/mod_passenger.so - create /etc/apache2/mods-availible/passenger-rvm.conf to contain:
PassengerRoot /home/passenger/.rvm/gems/ruby-1.9.2-p0/gems/passenger-2.2.15
PassengerRuby /home/passenger/.rvm/bin/passenger_ruby - sudo a2enmod passenger
- sudo /etc/init.d/apache2 restart
- create /etc/apache2/mods-availible/passenger-rvm.load to contai
On Your Development Machine (Once)
- gem install capistrano
For Each Application
- On The Client:
- First Deployment:
- cd <Application_Directory>
- capify .
- edit config/deploy.rb
- cap deploy:setup
- Subsequent Deployment:
- cap deploy:migrations (if database migrations)
- cap deploy
- First Deployment:
- On The Server
- Point apache to the public directory of the app:
- For a directory of an existing site use:
RailsBaeURI <URL to public folder of app> - For a (sub)domain use:
DocumentRoot <URL to public folder of app>
- For a directory of an existing site use:
- Point apache to the public directory of the app: