nginx + php-fpm =找不到文件 [英] nginx + php-fpm = File not found
本文介绍了nginx + php-fpm =找不到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试访问info.php
时,出现File not found.
错误.
When i try accessing info.php
I get a File not found.
error.
我尝试了一些教程无济于事.
I tried some Tutorials to no avail.
配置: 默认值:
server {
listen 80;
listen [::]:80 default ipv6only=on;
server_name localhost;
location / {
root /var/www;
index index.html index.htm index.php;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:7777;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
fastcgi_buffers 256 128k;
#fastcgi_buffer_size 16k;
#fastcgi_busy_buffers_size 256k;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
include fastcgi_params;
}
}
出什么问题了?
推荐答案
如果该info.php位于/var/www中,则指示fast_cgi查找是错误的
If that info.php is in /var/www, then it's wrong to instruct fast_cgi to look for
/usr/share/nginx/html/info.php;
为html和php使用相同的根目录.另外,root
和index
参数应位于特定位置之外,除非是非常特定的用途.
Use the same root for html and php. Also, root
and index
parameters should be outside a particular location except for very specific uses.
server {
listen 80;
listen [::]:80 default ipv6only=on;
server_name localhost;
root /var/www;
index index.html index.htm index.php;
#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:7777;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffers 256 128k;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
include fastcgi_params;
}
}
不用说,您仍然需要确保您的php-fpm服务正在侦听端口7777.常见的情况是让它在侦听端口9000.
needless to say, you still need to make sure your php-fpm service is listening at port 7777. Common case is to have it listening at port 9000.
这篇关于nginx + php-fpm =找不到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文