我有以下配置:
server {
listen 80 default_server;
access_log /var/www/logs/access.log;
error_log /var/www/logs/error.log error;
root /var/www/web/;
index index.html index.php;
server_name _;
location / {
try_files $uri $uri/ =404;
}
# HACK: This is temporary to work around renaming dozens of HTML links
location ~ \.htm$ {
root html;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.htm;
include fastcgi_params;
}
# HACK: This is temporary to work around renaming dozens of HTML links
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
我更新了/etc/php5/fpm/pool.d/www.conf添加了这行:
security.limit_extensions = .php .html
重新启动FPM和NGINX但是当我访问.html文件时,PHP没有呈现...... * .php文件按预期执行...
我还缺少什么?
答案 0 :(得分:1)
我会删除它:
# HACK: This is temporary to work around renaming dozens of HTML links
location ~ \.htm$ {
root html;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.htm;
include fastcgi_params;
}
然后使用它:
location ~ \.(php|html|htm)$ {
root html;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.html;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
我希望这能解决你的问题。