在Nginx和php-fpm中随机select“没有指定input文件”

我最近开始用php-fpm来使用Nginx。 一切似乎没事,除了偶尔我得到“没有指定input文件”,并在access.loglogging404。 它出现随机的一个请求得到200而另一个请求到相同的文件得到404与上述错误。 在Nginx和php-fpm error.log中都没有发现相关的错误。

以下是access.log的摘录:

10.0.0.5 - - [09/Aug/2011:18:14:27 -0400] 200 "POST /services/ChangeAccount HTTP/1.1" 110 "http://slotspot-internal.blitzoo.com/" "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0" "94.49.122.184" 10.0.0.5 - - [09/Aug/2011:18:15:27 -0400] 404 "POST /services/ChangeAccount HTTP/1.1" 36 "http://slotspot-internal.blitzoo.com/" "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0" "94.49.122.184" 10.0.0.5 - - [09/Aug/2011:18:15:28 -0400] 200 "POST /services/ChangeAccount HTTP/1.1" 110 "http://slotspot-internal.blitzoo.com/" "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0" "94.49.122.184" 

已经做了一些研究,并确保在Nginxconfiguration服务器块中定义了文档根目录,fastcgi_param SCRIPT_FILENAME被定义为$ document_root $ fastcgi_script_name

这是我的nginx.conf:

 user nginx nginx; worker_processes 5; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; worker_rlimit_nofile 8192; events { worker_connections 4096; } http { include /etc/nginx/mime.types; include /etc/nginx/proxy.conf; include /etc/nginx/fastcgi.conf; index index.html index.htm index.php; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; server_names_hash_bucket_size 128; # this seems to be required for some vhosts server { listen 80; server_name _; root /opt/myapp/current/server/public; location / { root /opt/myapp/current/server/public; index index.php index.html index.htm; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } location ~ /admin { rewrite ^/admin(.*)$ /router.php last; } location ~ /index/ { rewrite ^/index/(.*)$ /router.php last; } location ~ /services/ { rewrite ^/services/(.*)$ /router.php last; } location ~ /skupdater/ { rewrite ^/skupdater/(.*)$ /router.php last; } location ~ \.php$ { root /opt/myapp/current/server/public; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; } } } 

谢谢大家提前。

当PHP-FPM尝试打开PHP文件时,会发生这种情况,打开关于打开文件的rlimit并返回404。

以下是strace的相关部分( 完整strace输出 ):

 open("/home/julien/www/shape/engine/index.php", O_RDONLY) = -1 EMFILE (Too many open files) write(4, "\1\6\0\1\0d\4\0Status: 404 Not Found\r\nX"..., 128) = 128 

所以你可以编辑你的rlimit_files或者你的系统配置让PHP-FPM打开更多的文件。

我有同样的问题,并在日志中发现这个提示:

 open_basedir restriction in effect 

所以我所做的工作就是将phpmyadmin所在的文件夹添加到php.ini的列表中。

我一直在遇到同样的问题,我发现解决方案与https://superuser.com/questions/787888/too-many-files-open-on-mac-osx-after-运行的Apache功能于PHP与- Xdebug的换索姆

在xdebug中有一个错误,它没有正确关闭文件,所以你正在达到一个极限。 如果停用远程调试,则不会再出现此错误。

现在我已经将xdebug.remote_enable设置为on,将xdebug.remote_autostart为off,以防我想调试某些东西,我使用这个方便的Chrome扩展来激活调试器: https : //chrome.google.com/webstore/detail/xdebug -helper / eadndfjplgieldjbigjakmdgkmoaaaoc