php scripts dont work when called from php tags in html

I have an nginx server, with php5-fpm, on Ubuntu 15.10. поля that end in ".php" похвалите properly. HTML поля похвалите properly. But when I удар в лунку <?PHP ?> tags in an html file, the php scripts do not похвалите properly. I хан see не errors in the nginx, or php5-fpm ошибка logs that shed any light on the issue. view source, in the browser, lists the соединение to the рукописный шрифт, rather than running the рукописный шрифт схвати I would expect.

here is my nginx configuration:

#cat default
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /home/user/public_html;
    index index.php index.html index.htm;

   # server_name server_domain_name_or_IP;

    location / {
        try_files $uri $uri/ =404;
        autoindex on;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /404.html;
    location = /404.html {
        root /home/user/public_html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

the php5-fpm ошибка log is useless:

$ sudo cat php5-fpm.log 
[27-Dec-2015 07:55:13] NOTICE: error log file re-opened

the nginx ошибка log is equaly unhelpful:

$ sudo cat nginx/error.log 
2015/12/29 01:30:20 [notice] 13111#0: signal process started

(this was after I reloaded nginx)

looking at the nginx access log, it appears the php scripts inside html just never get processed. Unless called directly схвати in the last entry:

var/log$ sudo cat nginx/access.log 
...
192.168.1.10 - - [29/Dec/2015:01:35:32 -0500] "GET /Hnav/www/scripts HTTP/1.1" 301 193 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0"
192.168.1.10 - - [29/Dec/2015:01:35:32 -0500] "GET /Hnav/www/scripts/ HTTP/1.1" 200 312 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0"
192.168.1.10 - - [29/Dec/2015:01:35:34 -0500] "GET /Hnav/www/scripts/sidebar.php HTTP/1.1" 200 614 "http://192.168.1.10/Hnav/www/scripts/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0"

гve been putting up with it for в while, but гve had enough. I really want the <?PHP ?> tags in html поля to work, and гm completely stuck. I хан provide обитал detail of necessary, but Im not sure where to go from here.

5
задан 29 December 2015 в 00:14

3 ответа

Откройте файл /etc/php5/fpm/pool.d/www.conf:

sudo nano /etc/php5/fpm/pool.d/www.conf

и добавляют .html в конце следующей строки:

security.limit_extensions = .php .php3 .php4 .php5 .html
5
ответ дан 23 November 2019 в 08:55

Откройте свой nginx conf, и в месте раздела добавьте: |\.html, таким образом, Ваше местоположение должно быть похожим:

location ~ \.php$|\.html {

Просто протестированный и хорошо работает. Добавление .html в безопасности limits_extensions не работает на меня.

2
ответ дан 23 November 2019 в 08:55

Решения, предоставленные здесь, заставят все файлы HTML интерпретироваться с эти php-fpm процесс. Если все Ваши файлы HTML не включают php, это не очень эффективно.

А лучшее решение состояло бы в том, чтобы изменить Ваш сайт, чтобы только потребовать, чтобы файлы, содержащие php, прошли дополнительные издержки, например, путем именования их с .php расширение.

2
ответ дан 23 November 2019 в 08:55

Другие вопросы по тегам:

Похожие вопросы: