R
R
Roman Ilyin2012-06-16 14:19:22
Nginx
Roman Ilyin, 2012-06-16 14:19:22

How to make nginx interpret html files as php?

There is an nginx+phpfpm server.
Files with the .php extension are returned normally, but in the .htm/.html files, the php code is returned as source text without being broadcast. How to make nginx broadcast html files with php code?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
NiGHt_LEshiY, 2012-06-16
@GeForester

I suggested it in a comment to the question, I'm posting it as an answer (for those who encounter this problem).
1. nginx should pass html files to the fastcgi backend. To do this, you need to change the Location, where the processing of php files is registered, or add a new Location.

location ~ .(php|html)$ {
 fastcgi_pass ...
 fastcgi_index index.php;
 fastcgi_param ...
 include fastcgi_params;
 }

2. php-fpm by default refuses to process files that do NOT end with ".php"
In php-fpm.conf (or in your pool config if you have a division into pools) you can add the line:
security.limit_extensions = .php .html
Remember that this is a security setting . Be sure to think about the possible consequences.

A
Anatoly, 2012-06-16
@taliban

And what do you really care what extension the vile has? You can add internal redirects from *.html to *.php in nginx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question