Question

Parse HTML as PHP w/ LEMP stack

I installed the LEMP package from the marketplace, and I’d like to host a website that relies on having HTML files parsed as PHP. I can find instrucions for doing this with Apache, but not nginx. Is there an easy way to do this, or should I just start over with a LAMP installation?

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Yes, this is also doable with Nginx as well as Apache.

You need to duplicate the .php location rule and add one for .htm$.

So the configuration will look like this, depending on yuor PHP configuration:

    location ~ \.htm$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

Hope that this helps. Regards, Bobby