gpt4 book ai didi

php - NGINX - 将 html 文件映射到 php

转载 作者:行者123 更新时间:2023-11-28 03:42:09 25 4
gpt4 key购买 nike

我无法让 nginx 读取嵌入在特定目录 (html/test) 的 .html 文件中的 php 代码。我运行 CentOS 6 并安装了 FastCGI。我尝试了几种配置,但没有任何效果。我的 nginx.conf 看起来像这样:

worker_processes  1;

events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

sendfile on;


keepalive_timeout 65;

server {

server_name www.domain.com;
rewrite ^(.*) http://domain.com$1 permanent;


}
server {
listen 80;
server_name shop-munk.com *.shop-munk.com;


location / {
root /opt/html;
index index.html index.htm index.php;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /opt/html;
}


location ~ \.php$ {
root opt/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /$fastcgi_script_name;
include fastcgi_params;
}

location ~ \.html$ {
root opt/html/test;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.html;
fastcgi_param SCRIPT_FILENAME /$fastcgi_script_name;
include fastcgi_params;
}


}


}

最佳答案

我试图做同样的事情,服务器为没有 .php 扩展名的脚本返回“403 Forbidden”。以下 PHP-FPM 配置解决了问题:

security.limit_extensions = .php .html

关于php - NGINX - 将 html 文件映射到 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9994544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com