部署 nginx + passenger 配置不成功,请各位帮忙!!

kaka · 2012年01月03日 · 最后由 hiveer 回复于 2015年05月25日 · 17733 次阅读
kakamatoiMac:/ kaka$ sudo nginx -t
Password:
nginx: [emerg] unknown directive "passenger_root" in /usr/local/nginx/conf/nginx.conf:18
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

nginx.conf 18 行

passenger_root /Users/kaka/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.11;
passenger_ruby /Users/kaka/.rvm/wrappers/ruby-1.9.2-p290/ruby;

这个错误是我的 passenger 没有配置好吗?新手求解 谢谢

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable (/Users/kaka/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.11/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. (-1: Unknown error)
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

passenger 需要编译 nginx 的时候链接进去的,LZ 应该是没有正确编译

#1 楼 @Rei 是没有正确编译吗?那要重新编译 nginx

#2 楼 @kaka passenger 有一个 passenger-install-nginx-module 脚本帮助编译 nginx

配置文件 nginx 的所在目录不对~

运行 passenger-install-nginx-module 的时候,选择 Yes, Download and compile Nginx.

楼主用的是 Mac 么?这里有一篇 wiki http://ruby-china.org/wiki/mac-nginx-passenger-rails

#9 楼 @lgn21st 谢谢回复 我是根据这个去部署的,就是在 sudo nginx -t 测试有点问题!被卡住了,请大侠帮忙

#10 楼 @kaka 应该是你的 nginx 没有安装正确,或者 rvm 有问题。从错误消息来看,nginx 在 activate passenger 的时候无法在指定目录找到 PassengerWatchdog,那么 passenger 在自送安装 nginx 的时候把这这个安装到什么地方去了呢?

#11 楼 @lgn21st 现在 sudo nginx -t 可以通过了,但是 sudo nginx 启动时出下面这种情况! nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use) nginx: [emerg] still could not bind()

#11 楼 @lgn21st 刚才那个是端口占用了

#12 楼 @kaka 这是因为 nginx 已经被启动起来了,80 端口已经被占用了,或者 80 端口被其他进程占用。

重新加载 nginx 的配置文件:

nginx -s reload

停止 nginx 的方法

nginx -s stop

启动 nginx 的方法

nginx

#14 楼 @lgn21st 我可以改端口吗?

#15 楼 @kaka 这个...你想知道 nginx 如何改端口么?问 Google 比问我快。

#16 楼 @lgn21st 知道改端口!只是不确认!我现在打开本地域名报 404 错误..是不是还有那里没有改好啊

#17 楼 @kaka 这个要看 log,分别要看 nginx 的 log 和 rails 的 log,判断问题出在 nginx 这边还是 rails 端。

#18 楼 @lgn21st

2012/01/04 16:31:57 [error] 6726#0: *23 "/Users/kaka/kaka/public#html/index.html" is not found (2: No such file or directory), client: 127.0.0.1, server: kaka.local, request: "GET / HTTP/1.1", host: "kaka.local"
2012/01/04 16:31:57 [error] 6726#0: *23 open() "/Users/kaka/kaka/public#html/favicon.ico" failed (2: No such file or directory), client: 127.0.0.1, server: kaka.local, request: "GET /favicon.ico HTTP/1.1", host: "kaka.local"

我已经改了这个 root 路径 ,为什么还会找以前 /Users/kaka/kaka/public#html/index.html 这个路径呢!我重启了 Nginx

location / {
    root   /Users/kaka/Documents/soft/neza/public;    #html;
#index  /products/index
    index  index.html index.htm;
}

#19 楼 @kaka 贴完整的 nginx.conf 吧

worker_processes 1;

events { worker_connections 1024; }

http { passenger_root /Library/Ruby/Gems/1.8/gems/passenger-3.0.11; passenger_ruby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby;

include mime.types; default_type application/octet-stream;

sendfile on; keepalive_timeout 65;

server { listen 81; server_name kaka.local;

location / { root /Users/kaka/Documents/soft/neza/public; #html; #index /products/index index index.html index.htm; }

error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } #20 楼 @lgn21st

#21 楼 @kaka 比过 wiki 上的配置了么?

worker_processes  1;

events {
  worker_connections  1024;
}

http {
  passenger_root /Users/Daniel/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.10;
  passenger_ruby /Users/Daniel/.rvm/wrappers/ruby-1.9.2-p290/ruby;

  include       mime.types;
  default_type  application/octet-stream;
  sendfile      on;
  keepalive_timeout  65;

  server {
    listen 80;
    server_name awesome_project.local;
    root /Users/Daniel/awesome_project/public;
    passenger_enabled on;
    rails_env development;
  }
}
worker_processes  1;
events {
    worker_connections  1024;
}


http {
    passenger_root /Library/Ruby/Gems/1.8/gems/passenger-3.0.11;
    passenger_ruby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby;

        include       mime.types;
        default_type  application/octet-stream; 
        sendfile        on;

        keepalive_timeout  65;

    server
    {
         listen       81;
         server_name  kaka.local;
         location / {
            root   /Users/kaka/Documents/soft/neza/public;    #html;
            index  index.html index.htm;
         }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

#22 楼 @lgn21st 已经打开本地域是 404 错误,重启一下电脑就连接不到服务器了

#22 楼 @lgn21st 真的麻烦你了 重启一下 nginx 可以打开本地域 403 没有权限不知道说那个文件没权限

2012/01/04 21:11:49 [error] 559#0: *3 "/Users/kaka/Documents/soft/neza/public/index.html" is forbidden (13: Permission denied), client: 127.0.0.1, server: kaka.local, request: "GET / HTTP/1.1", host: "kaka.local"

这个问题解决了吗?貌似我也有这个情况。

这个问题在升级 passenger 的时候比较容易发生,解决很简单

passenger_root /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.15;

改为passenger-config --root输出的目录

passenger_root /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17;

即可。

这么多大牛齐聚一贴,少见

需要 登录 后方可回复, 如果你还没有账号请 注册新账号