• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved Can't get php versions to serve .html as php

I got the second test file above, http://literaryfashion.com/ssi-test/index.php , working. The missing piece was turning on short_open_tag in domain > PHP Settings.

But HTML files are still not being parsed by PHP, no matter what combination of PHP version / PHP handler / Apache directives I try.

For PHP version I have mostly settled on "5.4.16 by OS vendor" -- other options tend to cause .php files to be downloaded instead of parsed.

For PHP handler I have tried

FastCGI application served by Apache
FPM application served by Apache
mod_php served by Apache

(The latter after first enabling support in Tools & Settings > Apache Settings "5.4.16 by OS vendor mod_php"-- but it does not seem to work. The help link "view the php_info() page" at domain > PHP Settings results in a blank page.)

With FastCGI, I have tried the Apache directives given above:

<IfModule mod_fcgid.c>
<Files ~ (\.html)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .html
Options +ExecCGI
Require all granted
</Files>
</IfModule>

No parsing of PHP in HTML files.

With FPM application, I have tried essentially all combinations of 1, 2, and all 3 of the following Apache directives:

AddType application/x-httpd-php .html
AddHandler x-httpd-php .html
AddHandler php-script .html

Nothing results in PHP parsing HTML files.

Now what?
 
I have marked this as unresolved since I still don't have it working - had to get on with something else but now I'm right back on it again...
I am still unable to get .htm/.html files to execute as php with anything else but apache module...
 
Ah - finally have it working! My mistake was to not notice that in:
<IfModule mod_fcgid.c>
<Files ~ (\.html)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .htm
Options +ExecCGI
Require all granted
</Files>
</IfModule>
...I had a mismatch between the ".html" in the 'Files' line and the ".htm" FCGI wraper line...
It appears that this syntax works for both fast cgi and fpm
Thanks for all your help. :)

Just wondering now What is the syntax for enabling more than one file type (i.e. .htm AND .html) to be processed by the fast-cgi php processor... ?
 
oh and one last issue that I have run into on a particular site...
When I add the above code to the apache directives, the .htm files get processed as php but I get a 404 error with the index page if I go to "http: // mydomain.com"
The error in the log is:
AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: https://www.mydomin.com/css/main.css

If I give the full path to the index file (https://www.mydomain.com/index.htm) all is well....
 
Last edited:
hmm there is an index.htm and an index.html file in the root. The index.htm was always the one that was getting served by default. By adding:
DirectoryIndex index.htm index.php index.html
...it is now working again...
I discovered this is down to the fact that .html files are not being interpreted as php (only .htm files) - the .htm is just an include of the .html (don't ask me why!).

I worked out the reply to my earlier question - how to serve .htm & .html files as php (this fixed the problem so I could remove the DirectoryIndex entry):
<IfModule mod_fcgid.c>
<Files ~ "\.(htm|html)>
SetHandler fcgid-script
# FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .htm
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .html
Options +ExecCGI
Require all granted
</Files>
</IfModule>
 
Last edited:
Hi theWoosh -- FWIW I still have not gotten php parsing of html files working. Everything is as it was at my last post at the end of May. Any further suggestions very welcome.
 
I asked support and within a few hours they sent me the info on connecting to the PHP-FPM socket:

1) add this to "Apache & nginx Settings" for the domain under "Additional directives for HTTPS" (and/or HTTP):

<IfModule mod_proxy_fcgi.c>
<Files ~ (\.html$)>
SetHandler proxy:unix:///var/www/vhosts/system/yourdomain.example.com/php-fpm.sock|fcgi://127.0.0.1:9000
</Files>
</IfModule>

2) I also found to avoid an access denied error I had to add the desired extension to "security.limit_extensions" in the PHP settings for the web site, under "Additional directives":

[php-fpm-pool-settings]
security.limit_extensions=.php .phar .html

(the default is ".php .phar" per PHP: Configuration - Manual)

For FastCGI there is a KB article How to configure Apache to process PHP code inside an .html file on a Plesk server which it looks like they updated for PHP-FPM already.
 
Back
Top