eg:linux
好比說在linux下運行rails自帶的服務器時,須要這樣的命令RAILS_EVN=production rails s是否是有點囉嗦呀,每次要打這麼多字,不能忍,萬幸的是咱們有shell腳本的幫助。創建一個本身的腳本吧:shell
touch 一個rails_s.sh而後用vim編輯以下,保存。vim
#!/bin/bash RAILS_EVN=production rails s
執行如下命令:ruby
echo $PATH
顯示路徑信息以下:bash
sophia@DIU:~/Downloads/sublime_text_3$ echo $PATH /home/sophia/.rvm/gems/ruby-2.1.3/bin:/home/sophia/.rvm/gems/ruby-2.1.3@global/bin:/home/sophia/.rvm/rubies/ruby-2.1.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sophia/.rvm/bin:/home/sophia/.rvm/bin:/home/sophia/.rvm/bin
能夠看到裏面有/usr/local/bin一項,把寫好的rails_s.sh放到/usr/local/bin中,而後改一下權限:服務器
sudo chmod 755 rails_s.sh
如今就能夠到項目目錄(eg:/var/www/Blog/)下使用rails_s.sh命令執行該腳本啓動服務器了:app
sophia@DIU:/var/www/ashelf$ rails_s.sh => Booting WEBrick => Rails 3.2.12 application starting in production on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server