我試圖在linode VPS上部署一個rails應用程序。爲了部署目的,我創建了deployer
用戶。Rails 4.1.6 APP:NGINX:「/ var/www/your_own_store/current/public /」的目錄索引被禁止
我已經安裝了ruby/rails/passenger使用rvm。
我/opt/nginx/conf/nginx.conf是如下:
http {
passenger_root /home/deployer/.rvm/gems/ruby-2.1.3/gems/passenger-4.0.52;
passenger_ruby /home/deployer/.rvm/rubies/ruby-2.1.3/bin/ruby;
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
server {
listen 80;
server_name myserver;
passenger_enabled on;
rails_env production;
root /var/www/your_own_store/current/public;
#charset koi8-r;
#access_log logs/host.access.log main;
nginx的重啓之後,我的403頁。和error.log如下:
2014/09/30 13:33:24 [error] 27388#0: *27 directory index of "/var/www/your_own_store/current/public/" is forbidden, client: 1.39.62.158, server: myserver, request: "GET/HTTP/1.1", host: "myhost"
調試近2天之後,我覺得這個問題可能是因爲這一點:
連接到服務器,除非我做後
$ source ~/.bash_profile
我看到我的rails版本爲1.9.3。而乘客在不同的地方安裝,如下圖所示:
[email protected]:/opt/nginx/logs# passenger-config --root
/var/lib/gems/1.9.1/gems/passenger-4.0.52
[email protected]:/opt/nginx/logs# su deployer
[email protected]:/opt/nginx/logs$ passenger-config --root
/var/lib/gems/1.9.1/gems/passenger-4.0.52
[email protected]:/opt/nginx/logs$ source ~/.bashrc
[email protected]:/opt/nginx/logs$ passenger-config --root
/var/lib/gems/1.9.1/gems/passenger-4.0.52
[email protected]:/opt/nginx/logs$ source ~/.bash_profile
[email protected]:/opt/nginx/logs$ passenger-config --root
/home/deployer/.rvm/gems/ruby-2.1.3/gems/passenger-4.0.52
[email protected]:/opt/nginx/conf# ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
[email protected]:/opt/nginx/conf# su deployer
[email protected]:/opt/nginx/conf$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
[email protected]:/opt/nginx/conf$ source ~/.bash_profile
[email protected]:/opt/nginx/conf$ ruby -v
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]
我不知道這是否是問題的根源。如果是這樣,如何解決它?
早些時候,我已經安裝了所有的東西,作爲root
,它的工作就像魅力。
任何人都可以幫助我嗎?
謝謝
更新:我可以找到默認的紅寶石設置的解決方案。 原因是,作爲用戶登錄時,系統資源.bash_profile,而如果我做'su',它的非登錄shell。所以它只是源碼.bashrc而不是.bash_profile。
所以添加以下行的.bashrc後,我能找到的 '蘇' [-s 「$ HOME/.rvm /腳本/ RVM」]] & &源「$ HOME /後正確的紅寶石版本。 RVM /腳本/ RVM」#加載RVM成shell會話作爲功能
Here是我在unix.stackexchange發現的解釋參考。