我在生产服务器上安装了一个rails应用程序,其中安装了Passenger和Nginx(带有Passenger模块)。但是,当我运行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
最佳答案
这里是Phusion乘客作者。我99%肯定这只是Nginx配置错误。
首先,Phusion Passengerstarts your app at the first request,所以您看到“0进程”是很正常的,除非显式地用passenger_pre_start配置。
这条线索是,当你试图访问你的网站时,你会看到“欢迎来到nginx”。在99%的情况下,这意味着您的虚拟主机配置错误。由于您修改了配置文件,我无法告诉您到底是什么错误,但它表明Nginx没有将您的请求与您希望它与之关联的虚拟主机块关联。如果你发布你的未经修改的配置文件和你正在访问的URL,我可以告诉你更多。否则,我只能告诉您研究Nginx的服务器名匹配是如何工作的。
关于ruby-on-rails - Nginx和Phusion乘客正在运行,但乘客状态显示0个进程正在运行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27608262/