我有 NginX 使用 fcgi 为 drupal 站点提供服务。尝试浏览不存在的 php 文件(例如 www.example.com/this-file-doesn't-exist.php)会导致出现以下错误的白屏:
'未指定输入文件'
我用这篇文章来帮助我设置 NginX:http : //drupal.org/node/110224
这是我的 NginX 配置文件:
server {
listen 1.2.3.4:80 default;
server_name www.example.com;
client_max_body_size 6M;
root /var/www/example.com/;
index index.php;
error_page 404 /index.php;
error_page 403 /403.html;
# set up a location to serve static images for static error pages
location ^~ /error_images/ {
root /var/www/static_pages/error_pages;
access_log off;
expires 30d;
}
# use our own custom 403 page
location = /403.html {
root /var/www/static_pages/error_pages;
}
# redirect server error …Run Code Online (Sandbox Code Playgroud) 我正在使用 fastcgi 在 nginx 之上运行 django。当我执行 runfcgi 时,我看到这些错误:
python manage.py runfcgi daemonize=false host=127.0.0.1 port=8000
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Run Code Online (Sandbox Code Playgroud)
在我的 nginx 错误日志中,我看到了这个:
2011/01/31 10:33:16 [error] 15921#0: *4 FastCGI sent in stderr: "WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!" while reading upstream, client: ::1, server: …Run Code Online (Sandbox Code Playgroud) 我正在构建一个环境(在 ubuntu 10.04.02 机器上)来处理具有许多(应该支持至少 1000 个)子域的网站,每个子域由不同的 FPM 池提供服务,并具有不同的用户。
所以没有什么新鲜事;我的问题是创建(并启动)一个新的 fpm 池,而不必重新加载/重新启动 FPM,这会导致(我知道,非常快)停机。
我写了一个 python 守护进程,在需要时:
我四处搜索,但没有找到使用一个池调用 fpm 的方法,这可能是一个“临时”解决方案:主 fpm 实例运行所有池,每个新实例都有自己的 fpm 实例,然后使用 cron 我停止并每周/每月/不知道重新加载 fpm
如果确实重要,服务器在 nginx 上运行,配置为使用 unix socket to fcgi,这是我的 nginx 测试配置:
server{
listen 80;
server_name ~^(?<domain>.+)\.test\.local$; # foo.test.local > myapp_foo
root /var/www/myapp/subdomains/myapp_$domain/htdocs;
location / {
index index.php;
}
location ~* \.(gif|jpg|png|ico)$ {
expires 30d;
}
location ~ \.php$ {
fastcgi_pass unix:/var/web-sock/myapp_$domain-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 apache2 和 nginx 使用 php7.0-fpm 构建一个 dockerized ubuntu 16.04lts
我使用过但没有用的命令
[program:php-fpm7.0]
command = /usr/sbin/php-fpm7.0 --daemonize --fpm-config /etc/php/7.0/fpm/php-fpm.conf
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
Run Code Online (Sandbox Code Playgroud)
和
[program:php-fpm7.0]
command = /usr/sbin/php-fpm7.0 -c /etc/php/7.0/fpm/php-fpm.conf
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
Run Code Online (Sandbox Code Playgroud)
和
[program:php-fpm7.0]
command = /usr/sbin/php-fpm7.0 -c /etc/php/7.0/fpm
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
Run Code Online (Sandbox Code Playgroud)
以下是我尝试作为容器运行时来自 docker 的错误日志
从 apache2 容器
2016-06-26 20:04:21,488 CRIT Set uid to user 0
2016-06-26 20:04:21,496 INFO RPC interface 'supervisor' initialized
2016-06-26 20:04:21,496 CRIT Server 'unix_http_server' running …Run Code Online (Sandbox Code Playgroud) 运行 apache httpd 2.2.11 和 fastcgi 的 debian lenny 服务器在请求超过特定秒数时终止请求。我想禁用此超时以使我能够调试使用 fastcgi 启动的应用程序。
我已经在 apache 和 lighttpd 文档中搜索过,但找不到任何东西(只有空闲超时之类的选项,我认为这里不是这种情况)。
有谁知道如何控制这个超时?谢谢。
我在 AMAZON EC2 上有一台服务器,通过端口 9000 运行带有 PHP FASTCGI 的 Nginx + PHP。
服务器运行了几分钟,一段时间后(在这种情况下有数千次点击)FastCGI 失效,Nginx 返回 502 错误。
Nginx 日志显示
2010/01/12 16:49:24 [error] 1093#0: *9965 connect() failed (111: Connection refused) while connecting to upstream, client: 79.180.27.241, server: localhost, request: "GET /data.php?data=7781 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "site1.mysite.com", referrer: "http://www.othersite.com/subc.asp?t=10"
Run Code Online (Sandbox Code Playgroud)
如何调试导致 FastCGI 死亡的原因?
我正在尝试使用以下说明在 Windows 7 Home Premium 上安装 PHP:
使用 FastCGI 在 IIS 7 上托管 PHP 应用程序
在页面向下的 1/3 处,我必须这样做:
Server Manager -> Roles -> Add Role Services
Run Code Online (Sandbox Code Playgroud)
只是找不到角色或角色服务。有任何想法吗?
PHP 给了我一个 500 错误,我想知道是不是因为我没有做过这个角色服务。
我有一个专用服务器运行 debian 6、nginx 1.07、php 5.3、php-fpm 和 percona mysql 5.1。
我最近刚刚设置了服务器,只有 1 个站点在其上运行。
我遇到的问题是,即使我设置了 10 个 php fastcgi 进程,但 1 个 php5-cgi 进程消耗 100% cpu,而其他 9 个进程消耗几乎 0%。此时,整个服务器都很慢,站点也是如此。
我在安装php-fpm与apache2-mpm-worker. Ť他是导向,我以下。
根据指南的第 5 步,
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
Run Code Online (Sandbox Code Playgroud)
但是我php5-fcgi在/usr/lib,但只有/usr/bin/php5-cgiand找不到,/usr/bin/php-cgi我不确定它们是否相同。
所以我将步骤 5 中的行更改为:
Alias /php5-fcgi /usr/bin/php5-fcgi
FastCgiExternalServer /usr/bin/php5-fcgi -host 127.0.0.1:9000 -pass-header
Run Code Online (Sandbox Code Playgroud)
在重新启动 Apache 时,它的日志给出了错误:
[notice] caught SIGTERM, shutting down
[alert] (4)Interrupted system call: FastCGI: read() from pipe failed (0)
[alert] (4)Interrupted system call: FastCGI: the PM is shutting down, Apache seems to have disappeared - bye
[notice] Apache/2.2.22 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 configured …Run Code Online (Sandbox Code Playgroud) 在许多语言中,您从头开始构建 Web 框架(即从 unix 套接字)并在抽象层上构建。如果我想用 OCaml 或 C 从头开始构建一个 web 框架,我首先构建一个侦听端口 80 的套接字服务器。
我突然想到 PHP - 就像任何其他高级语言一样 - 可能会以某种方式包装 unix 套接字。现在我知道情况是这样的,PHP 从来就不是这样设计的。但是,我不明白为什么它从未以这种方式使用过。按照同样的思路,PHP 解释器从未像 Python 解释器那样以这种方式使用。
例如,当我从头开始构建 Python Web 服务器并部署它时,我执行以下操作:在某个端口(比如 8000)上添加一个 unix 套接字,像 一样守护我的脚本python server.py 8000,并在端口 80 上设置 nginx 反向代理并转发到我的端口 8000 上的内部本地服务器。我从未见过用 PHP 完成的,即使它是可能的。
我承认,除了使用独立的解释器(即 Tornado、uwsgi 等)之外,您在 Python 中还有其他选择。然而,它是双向的。
我的问题是,PHP 语言、解释器或社区的哪些方面阻止了 PHP Web 框架从 unix 套接字调用从头开始构建、在本地端口上进行守护进程以及被反向代理而不是使用 cgi/ fastcgi 包装器?