PHP in HTML (again, but for 1 site only)

You also need to:

1.- Edit php-fpm conf file for your domain. It should be here:
/etc/php/8.2/fpm/pool.d/domain.com.conf

And add at the end of file this directive.
security.limit_extensions = .htm

Save the file and restart php service.
systemctl restart php8.2-fpm

2.- Edit nginx conf files (both, normal and ssl)

/home/YourUser/conf/web/YourDomain/nginx.conf
/home/YourUser/conf/web/YourDomain/nginx.ssl.conf

And remove htm extension from both conf files:

Original:

location ~* ^.+\.(css|htm|html|js|json|xml|[...]

Modified:

location ~* ^.+\.(css|html|js|json|xml|[...]

Restart nginx:

systemctl restart nginx

And as you already modified apache2.conf:

    <FilesMatch \.htm$>
        SetHandler "proxy:unix:/run/php/php8.2-fpm-domain.com.sock|fcgi://localhost"
    </FilesMatch>

It should work fine now.

Note: Once you check whether it works, you would need to create customized php, nginx and apache templates for your domain with all these changes or the conf will be overwritten when rebuilding the web domain.

2 Likes