Nginx和Phusion Passenger运行但乘客状态显示0个进程正在运行

时间:2014-12-22 18:19:09

标签: ruby-on-rails linux nginx passenger

我在生产服务器上安装了一个带有Passenger和Nginx(带有Passenger模块)的rails应用程序。但是,当我去运行rvmsudo passenger-status时,它会显示0个进程正在运行。

供参考,这是我的nginx.conf:

#user www-data;
user root;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

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

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
    #passenger_ruby /usr/bin/ruby;
    passenger_ruby /usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

}

/etc/nginx/sites-enabled/目录包含相关的服务器信息。

以下是ps aux | grep nginx的输出:

root     11417  0.0  0.0  42412  1076 ?        Ss   13:13   0:00 nginx: master process /opt/nginx/sbin/nginx
nobody   11418  0.0  0.0  42852  1844 ?        S    13:13   0:00 nginx: worker process

当我通过网络浏览器访问该网站时,我得到了一个"欢迎来到nginx!"登陆页面。

我是这个东西的新手,所以可能会有一些简单的事情,但我只需要启动它。任何帮助将不胜感激。

编辑:

rvmsudo passenger-status的输出:

Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. Run:

export rvmsudo_secure_path=1

to avoid the warning, put it in shell initialization file to make it persistent.

In case there is no `secure_path` in `/etc/sudoers`. Run:

export rvmsudo_secure_path=0

to avoid the warning, put it in shell initialization file to make it persistent.
Version : 4.0.42
Date    : 2014-12-22 14:04:17 -0500
Instance: 11417
----------- General information -----------
Max pool size : 6
Processes     : 0
Requests in top-level queue : 0

----------- Application groups -----------

rvmsudo passenger-memory-stats的输出:

Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. Run:

export rvmsudo_secure_path=1

to avoid the warning, put it in shell initialization file to make it persistent.

In case there is no `secure_path` in `/etc/sudoers`. Run:

export rvmsudo_secure_path=0

to avoid the warning, put it in shell initialization file to make it persistent.
Version: 4.0.42
Date   : 2014-12-22 14:07:57 -0500
------------- Apache processes -------------
*** WARNING: The Apache executable cannot be found.
Please set the APXS2 environment variable to your 'apxs2' executable's filename, or set the HTTPD environment variable to your 'httpd' or 'apache2' executable's filename.


---------- Nginx processes ----------
PID    PPID   VMSize   Private  Name
-------------------------------------
11417  1      41.4 MB  0.1 MB   nginx: master process /opt/nginx/sbin/nginx
11418  11417  41.8 MB  0.6 MB   nginx: worker process
### Processes: 2
### Total private dirty RSS: 0.71 MB


----- Passenger processes -----
PID    VMSize    Private  Name
-------------------------------
11399  218.3 MB  0.3 MB   PassengerWatchdog
11402  491.5 MB  0.4 MB   PassengerHelperAgent
11408  232.9 MB  1.1 MB   PassengerLoggingAgent
### Processes: 3
### Total private dirty RSS: 1.74 MB

2 个答案:

答案 0 :(得分:2)

Phusion Passenger作者在这里。我99%确定这只是一个Nginx配置错误。

首先,Phusion Passenger starts your app at the first request,所以你看到' 0过程'是正常的。 - 除非使用passenger_pre_start明确配置。

线索是你看到"欢迎来到nginx"当您尝试访问您的网站时。在99%的情况下,这意味着您将虚拟主机配置错误。由于您编辑了配置文件,我无法告诉您究竟是什么问题,但它表明Nginx没有将您的请求与您希望与之关联的虚拟主机块相关联。如果您发布未经编辑的配置文件以及您正在访问的网址,我可以告诉您更多信息。但除此之外,我只能告诉你研究Nginx的服务器名称匹配是如何工作的。

答案 1 :(得分:0)

@tagCincy:/etc/nginx/sites-enabled/下有一个文件,它看起来像这样:

server {
    listen 443;
    server_name  REDACTED;

    ssl  on;
    ssl_certificate  REDACTED;
    ssl_certificate_key  REDACTED;

    #auth_basic "REDACTED";
    #auth_basic_user_file  REDACTED;

    client_max_body_size  250m;
    client_body_buffer_size  128k;

    access_log  REDACTED;
    error_log  REDACTED;

    root  REDACTED;

    passenger_enabled  on;
    rack_env  production;

    location ~ ^/assets/ {
        add_header Cache-Control public;
        add_header ETag "";
        expires 1y;

        break;
    }

    # disable site via capistrano (cap deploy:web:disable)
    if (-f $document_root/system/maintenance.html) {
        rewrite  ^(.*)$  /system/maintenance.html break;
    }
}

server {
    listen  80;

    server_name  REDACTED;

    client_max_body_size  250m;
    client_body_buffer_size  128k;

    access_log  REDACTED;
    error_log  REDACTED;

    rewrite  ^ https://www.REDACTED.com$request_uri? break;
}