这是一个问了一千次的问题,因为我讨厌写帖子,所以我会阅读并搜索所有可能的文档,然后才能找到写作的烦人部分(对我来说).
所以我有Nginx& PHP-FPM启动并运行CentOS 7.2. PHP-FPM正在使用www.conf中正确声明的/var/run/php-fpm/php-fpm.sock:
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php-fpm/php-fpm.sock
这是我的mywebsite.conf:
server {
listen 80;
server_name www.mywebsite.net;
# note that these lines are originally from the "location /" block
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php${
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我在php.ini中也有cgi.fix_pathinfo = 0.
我重新启动/重新加载了Nginx和PHP-FPM服务,重新启动了整个服务器,什么也没得到.我无法显示.php文件,它们只是下载.
我错过了什么?
提前致谢.
解决方法:
Nginx配置中是否还有其他服务器块,尤其是listen 80 default或default_server指令?
还尝试将access_log和error_log添加到Nginx配置,以找出是否有任何访问该服务器的任何错误.
标签:php,nginx,centos
来源: https://codeday.me/bug/20190814/1658459.html