-
Notifications
You must be signed in to change notification settings - Fork 1
How to set up Rails on Ubuntu
turadg edited this page Dec 14, 2011
·
5 revisions
Here's a recipe for getting Rails and some key additions working on Ubuntu.
First install Ubuntu. This guide was written with 11.04, Natty Narwhal.
In a terminal,
# install tools
sudo apt-get install -y git curl
# install dependencies
sudo apt-get install -y build-essential libssl-dev libreadline5-dev zlib1g-dev check install
Set up rbenv and ruby-build
If for some reason you get an "unknown command: rbenv" error, this is because bash either hasn't loaded your .bash_profile or it hasn't been told to. A temporary fix (for the current terminal session) is to run . ~/.bash_profile
, but that only works for the current terminal iteration. A more permanent fix is to edit your .bashrc file and add source ~/.bash_profile
to the end somewhere. Be sure to restart your terminal, either by closing it and reopening it or by running exec $SHELL
.
Then with rbenv and ruby-build set up,
# install a ruby dist
rbenv install 1.9.3-p0
# set that ruby as the one to use
rbenv global 1.9.3-p0
# should output: ruby 1.9.3-p0 (2011-10-30 revision 33570)
ruby -v
# should output hello
ruby -ropenssl -rzlib -rreadline -e "puts :Hello"
# Nokogiri
sudo apt-get install libxslt-dev libxml2-dev
gem install nokogiri
# Postgres
sudo apt-get install postgresql pgadmin3
sudo apt-get install libpq-dev
gem install pg
# Capybara webkit
sudo apt-get install libqt4-dev
# Execjs
sudo apt-get install nodejs
# set yourself up as a Pg super user
sudo -u postgres createuser --superuser $USER
# make sure it works by creating your own db
createdb $USER
psql # this should run without error. exit with ^D
# create rails user with password 'rails'
createuser --echo --no-superuser --createdb --no-createrole --login --pwprompt rails
# test it out; you'll have to connect by TCP instead of local Ident auth
psql -h localhost -U rails postgres
# that should give a prompt (in the main 'postgres' database)
# to connect from Ruby/Rails change each auth METHOD line to 'trust'
# per http://oldwiki.rubyonrails.org/rails/pages/PostgreSQL
sudo vi /etc/postgresql/9.1/main/pg_hba.conf
# then restart
sudo /etc/init.d/postgresql restart
# get bundler
gem install bundler
# rehash the shims to put it in your path
rbenv rehash
# cd to where you want the repo, e.g.
cd Code
# clone the repo you want, e.g.
git clone [email protected]:turadg/Course-Check.git
# cd into it
cd Course-Check
# grab all the gem dependencies
bundle install
# make sure you can see the rake tasks
bundle exec rake -T
# set up the database
bundle exec rake db:setup
# start up the server
bundle exec rails server