我正在尝试将rails应用程序部署到运行乘客和nginx的Ubuntu服务器上。该服务器在ruby 1.8上运行了大约一年,但我最近升级到1.9.3(这次使用RVM),因此必须重新安装所有内容。我目前遇到两个问题:
我能够启动nginx服务器,但是当我尝试访问rails应用程序时,我收到403 Forbidden错误,内容如下:
*2177 directory index of "/srv/myapp/public/" is forbidden
我在nxinx help docs中做了一些调查并确保/srv/myapp/
目录具有适当的权限。它由拥有nginx工作进程的deploy
用户拥有,并设置为chmod 755
。
当我重新启动nginx服务器时,我还收到另一个错误,指出我的错误乘客安装有问题:
Unable to start the Phusion Passenger watchdog because its executable (/usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/agents/ PassengerWatchdog) does not exist. This probably means that your Phusion Passenger installation is broken or incomplete, or that your 'passenger_root' directive is set to the wrong value. Please reinstall Phusion Passenger or fix your 'passenger_root' directive, whichever is applicable.
我从非root(但启用了sudo)用户重新安装了乘客gem,并使用rvmsudo passenger-install-nginx-module
重新安装nginx,但后来我反复收到此错误:
Your RVM wrapper scripts are too old. Please update them first by running 'rvm get head && rvm reload && rvm repair all'.
我执行了RVM重新加载(包括rvmsudo
和没有),但仍然出现错误。我尝试在没有rvmsudo
的情况下执行nginx安装,但遇到了权限问题,因为我无法编辑/opt/nginx/
目录(我安装了nginx)。现在我甚至没有那么做,因为安装程序无法通过所需的软件检查。
这就是我的nginx流程目前的样子:
PID PPID USER %CPU VSZ WCHAN COMMAND
10174 1 root 0.0 18480 ? nginx: master process /opt/nginx/sbin/nginx
29418 10174 deploy 0.3 18496 ? nginx: worker process
29474 12266 1001 0.0 4008 - egrep (nginx|PID)
我一直在step-by-step guide记录我的安装过程以供进一步参考。请看看我如何设置我的新安装。
答案 0 :(得分:0)
尝试在此guide之后重新安装所有环境,并将您的Rails应用程序放在/ var / rails / your_app_dir上,并使用以下内容:
sudo chown deployment_user:www-data -R /var/rails/your_app_dir
使用此nginx.conf示例将所有部分放在一起:
user www-data;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/rvm/gems/ruby-2.0.0-p195/gems/passenger-4.0.5;
passenger_ruby /usr/local/rvm/wrappers/ruby-2.0.0-p195/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"';
log_format gzip '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
access_log logs/access.log gzip buffer=512k;
server_names_hash_bucket_size 64;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
##
# Virtual Host Configs
##
#include /opt/nginx/conf/*.conf;
include /opt/nginx/conf/sites-enabled/*;
}