在具有两个启用站点(默认和沙盒)的 vps 上安装 nginx 1.0.6 PHP5-FPM 5.3.8.1。两者都有不同的池 - 默认为 127.0.0.1:9001,沙盒为 unix:/tmp/php5-fpm.sock。
默认情况下,domain.com 的流量由 sandbox 提供,sandbox.domain.com 由 sandbox 提供。两者都可以很好地为 php 应用程序提供服务。
我决定在两者上都打开 pm.status_path - 默认是 /status1,沙盒是 /status。
我可以卷曲http://127.0.0.1/status1并获得回应。
pool: default
process manager: dynamic
start time: 10/Oct/2011:18:14:24 -0500
start since: 8771
accepted conn: 61
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 2
active processes: 1
total processes: 3
max active processes: 1
max children reached: 0
然而, http://127.0.0.1/状态返回“您正在寻找的页面暂时不可用。请稍后再试”
default 的规则非常标准。
location ~ ^/(status|status1|ping)$ {
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_pass 127.0.0.1:9001;
fastcgi_read_timeout 300;
fastcgi_intercept_errors on;
allow 127.0.0.1;
deny all;
}
有想法吗?
答案1
创建一个单独的location
for /status
,如下所示:
location /status {
fastcgi_pass unix:/tmp/php5-fpm.sock;
include fastcgi.conf;
fastcgi_intercept_errors on;
error_page 404 /error/404.php;
}
答案2
location /php-fpm-pool1 {
fastcgi_pass unix:/var/run/php5-fpm-pool1.sock;
fastcgi_param QUERY_STRING $query_string; #Allow ?json arg
fastcgi_param REQUEST_METHOD GET;
fastcgi_param SCRIPT_NAME /php-fpm-status;
fastcgi_param SCRIPT_FILENAME /php-fpm-status;
allow 127.0.0.1;
deny all;
}
location /php-fpm-pool2 {
fastcgi_pass unix:/var/run/php5-fpm-pool2.sock;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD GET;
fastcgi_param SCRIPT_NAME /php-fpm-status;
fastcgi_param SCRIPT_FILENAME /php-fpm-status;
allow 127.0.0.1;
deny all;
}