NGINX - Отображение HTML-файлов в php - PullRequest
2 голосов
/ 03 апреля 2012

Я не могу заставить nginx читать php-код, встроенный в файлы .html для определенного каталога (html / test). Я использую 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;
    }


    }


}

1 Ответ

0 голосов
/ 21 февраля 2013

Я пытался сделать то же самое, и сервер вернул «403 Forbidden» для сценариев без расширения .php.Следующая конфигурация PHP-FPM устранила проблему:

security.limit_extensions = .php .html
...