2015年2月28日 星期六

Ubuntu 12.04 安裝 Ruby on Rails

這篇已經說明的很清楚了,但我還是做個筆記。
http://blog.sudobits.com/2012/05/02/how-to-install-ruby-on-rails-in-ubuntu-12-04-lts/

1.先去github取得rails-installer.sh

2.執行 rails-installer.sh
sudo chmod +x rails-installer.sh
./rails-installer.sh

3.這時log顯示裝RVM出錯,於是先執行
curl -sSL https://rvm.io/mpapis.asc | gpg --import -

4.等key裝好了,再執行一次
./rails-installer.sh

5.安裝完成後log的提示
To start using RVM you need to run `source /home/chad/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.

6.接下來需要載入rvm
source ~/.rvm/scripts/rvm

7.然後就可以跑了,app_name可以改成自己定的名稱
rails new app_name
cd app_name
rails server

8.在本機開網頁試看看
http://localhost:3000

在命令列模式下按Ctrl-C可關閉server,那麼如何背景執行呢?
rails server -d
這個查help是可以知道,但是背景執行時如何關閉呢?如下:
kill -9 $(lsof -i :3000 -t)