前情提要
最近在研究如何將Rails專案部署到AWS EC2,網路上蠻多教學文章,但是尚未只看一篇就成功完成,因此在這邊整理一下所有資料.
實作過程
實作完全參照 - Ruby on Rails 實戰聖經
以下列出幾點我遇到的問題,有其他問題歡迎留言一同討論.
--------------------------------------------------------------------------------------------------------
Vi基本指令
vi主要是用來修改.conf檔案,以下是可能會用到的指令:i 開始編輯
esc 退出編輯
:wq 儲存並離開
:w 儲存
:q 離開
:w !sudo tee % 遇到onlyread檔案,強制儲存
--------------------------------------------------------------------------------------------------------
passenger.conf
確認裡面的路徑是不是正確,可以使用以下指令
取得passenger路徑
passenger-config --root
取得Ruby路徑
which ruby
安裝 Nginx + Passenger
在這個部分,有一個指令是
# Add our APT repository
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'
紅線xenial部分為目前Ubuntu版本,xenial指的是Ubuntu16.04版本,如果版本錯誤,安裝的時候會出現找不到套件的問題.
--------------------------------------------------------------------------------------------------------
安裝必要的gem
gem install execjs
這個Gem要記得安裝,不然還是會出現Message from application: There was an error while trying to load the gem ‘uglifier’. Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. 的錯誤。
--------------------------------------------------------------------------------------------------------
修改Gemfile
gem 'therubyracer', platforms: ruby
Gemfile裡面的therubyracer一定要打開,因為Ubuntu沒有內建JS編譯,需要打開後,在執行bundle install.
--------------------------------------------------------------------------------------------------------
查看錯誤訊息
完成所有教學,還是無法成功出現網頁,可以到 /var/log/nginx/error.log 查看錯誤報告
-------------------------------------------------------------------------------------------
參考文章
https://ihower.tw/rails/deployment.htmlgem install execjs
這個Gem要記得安裝,不然還是會出現Message from application: There was an error while trying to load the gem ‘uglifier’. Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. 的錯誤。--------------------------------------------------------------------------------------------------------
修改Gemfile
gem 'therubyracer', platforms: ruby
--------------------------------------------------------------------------------------------------------
查看錯誤訊息
完成所有教學,還是無法成功出現網頁,可以到 /var/log/nginx/error.log 查看錯誤報告
-------------------------------------------------------------------------------------------
http://blog.niclin.tw/posts/874388-rails-a-key-to-rails-disposal-deploy-on-a-vps
http://alanyeh20001.blogspot.tw/2016/06/deployamazon-ec2-part2nginxpassenger.html
http://kuro-sean-blog.logdown.com/posts/701033-rails-app-deploy-to-aws-ec2
沒有留言:
張貼留言