繁体   English   中英

NGINX-将html文件映射到php

[英]NGINX - Mapping html files to php

我无法让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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM