【发布时间】:2019-07-21 13:03:56
【问题描述】:
我在 CentOs 7 上配置了 Ngnix 服务器,它正在使用 html 查找,但是当我尝试打开 .php 文件时,它会被下载。 我正在使用 PHP7.2。 这是我的配置(我使用的是 123.123.123.123 而不是我的真实 ip):
server {
listen [::]:80 default_server ipv6only=on;
listen 123.123.123.123:80 default_server;
root /var/www/example.com/public_html;
index index.php index.html;
server_name 123.123.123.123;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
所以当我尝试访问 123.123.123.123/test/index.php 时,我正在下载文件。
如何强制 ngnix 执行 php 文件?
【问题讨论】: