我最近开始使用带有php-fpm的Nginx . 一切似乎都没问题,除了偶尔我得到“没有指定输入文件”和404.登录access.log . 它似乎是随机的,其中一个请求获得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"
做了一些研究并确保文档根目录在Nginx配置服务器块中定义,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;
}
}
}
提前谢谢大家 .
3 回答
这可能发生在PHP-FPM尝试打开PHP文件时,触及有关打开文件的rlimit并返回404 .
以下是一个strace的相关部分(complete strace output):
因此,您可以编辑rlimit_files或系统配置,以便让PHP-FPM打开更多文件 .
我遇到了同样的问题,并在日志中发现了这个提示:
所以我做的工作是将phpmyadmin所在的文件夹添加到
php.ini
中的列表中 .我遇到了同样的问题,我发现解决方案与https://superuser.com/questions/787888/too-many-files-open-on-mac-osx-after-running-apache-in-php-with-xdebug-for-som相同
xdebug中有一个错误,它没有正确关闭文件,所以你达到了极限 . 如果停用远程调试,则不再出现此错误 .
现在我已经将
xdebug.remote_enable
设置为on,并将xdebug.remote_autostart
设置为off,以防我想调试一些我正在使用这个方便的chrome扩展来激活调试器:https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc