【发布时间】:2019-12-17 19:15:32
【问题描述】:
我有centos服务器,它配置了php和nginx,当我重新启动时,当我输入ip地址而不是域地址时,php文件没有执行,它工作正常
虚拟主机的 nginx 配置
server {
listen 80;
server_name domainname.com;
rewrite ^ $scheme://www.domainname.com$request_uri? permanent;
}
server {
listen 80;
server_name www.domainname.com;
if ($http_x_forwarded_proto = 'http'){
return 301 https://$host$request_uri;
}
root /home/global/domainname.com;
index index.php index.html index.htm;
access_log /home/global/logs/access.log;
error_log /home/global/logs/error.log;
location = /favicon.ico {
log_not_found off;
}
location ~ \.php$ {
fastcgi_intercept_errors on;
#proxy_ignore_client_abort on;
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /home/global/domainname.com$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
【问题讨论】:
-
你能发布你的 nginx 配置吗?
-
@Araw,配置已添加,请检查相同
-
你只加
server_name www.domainname.com;,你需要加server_name your ip address here;
标签: php nginx nginx-config