• 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

theWoosh

Basic Pleskian
Hi
I have Plesk 12.5 running on Ubuntu 14.04 LTS with php 5.5 out of the box. I added PHP 5.6 via plesk so I can run a site on this instead of 5.5.
The site currently runs with php as apache module and unfortunately plesk only installs FPM & fastcgi.
I have found if I switch the site to anything other than apache module (on either 5.5 or 5.6), it breaks, as html pages containing php get downloaded instead of interpreted - in other words the addhandler and addtype apache directives (that are in a .htaccess file) seem to be ignored.

I have tried several things, including adding the following to the vhost.con file (found in https://kb.odin.com/en/115773 ):

#PHP is running as an Apache module:
<IfModule mod_php5.c>
AddHandler php5-script .php .html .htm
AddType text/html .php .html .htm
</IfModule>
#PHP is running as a FastCGI application
<IfModule mod_fcgid.c>
<Files ~ (\.html)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .html
Options +ExecCGI
allow from all
</Files>
</IfModule>

...this doesn't appear to make any difference at all - still can't access site with fast cgi selected.

The .htaccess file does appear to be being read.

I have also tried to configure php 5.6 as apache module using the suggestions here:
https://support.plesk.com/hc/en-us/...ecause-corresponding-Apache-module-turned-off but it didn't show up as an option in the control panel

Any ideas would be very welcome...
 
Hi theWoosh,

sometimes, things change... like KB - articles ( and URLs ^^ ) for example. Pls. read and follow the KB - article ( the previous KB - article https://kb.plesk.com/115773 is outdated by now ) :


... and make sure, that you didn't forget the "reconfigure" - command, after your edits at "/var/www/vhosts/system/YOUR-DOMAIN.COM/conf/vhosts.conf" ( this will replace possible, corresponding ".htaccess" - modifications! ). You may now as well check at for example "/var/www/vhosts/system/YOUR-DOMAIN.COM/conf/httpd.conf" ( or "httpd_ip_default.conf" ), that there have been some changes in your apache - configuration file, after the successfull "reconfigure" - command.


Since you are on Ubuntu 14.04, pls. investigate your current apache - webserver - configuration, with the output of the command ( logged in as user "root" on your server over a SSH - client, as for example "putty" ):

apachectl -V
and
apachectl -M

( or pls. post a screenshot of your Plesk Control Panel - Site: Home > Tools & Settings > Apache Web Server )​


If you experience any issues/errors/problems, pls. consider to investigate the "panel.log" and the apache2 - logs ( pls. post the logs, if you need help with the investigations! ):


Sometimes, it is as well a good idea to change the log - level ( TEMPORARILY! ), to get more informations in Plesk - log - files:





Apart from all, pls. keep in mind the "best" ( and recommended! ) configuration is to use the combination nginx+apache2+php-fpm these days. :)
 
Thanks for your reply.
It seems that the recommended additions to vhost.conf are identical in both those versions of the article - I couldn't see any difference, so I haven't changed my vhost.conf. I did do a reconfigure-all after making the changes.

Here are the outputs from apachctl:
# apachectl -V
Server version: Apache/2.4.10 (Ubuntu)
Server built: Aug 31 2016 15:54:08
Server's Module Magic Number: 20120211:36
Server loaded: APR 1.5.1-dev, APR-UTIL 1.5.3
Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="mime.types"
-D SERVER_CONFIG_FILE="apache2.conf"

# apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
actions_module (shared)
alias_module (shared)
auth_basic_module (shared)
auth_digest_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
dav_module (shared)
dav_fs_module (shared)
dav_lock_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
fcgid_module (shared)
filter_module (shared)
headers_module (shared)
include_module (shared)
mime_module (shared)
mpm_prefork_module (shared)
negotiation_module (shared)
perl_module (shared)
php5_module (shared)
proxy_module (shared)
proxy_fcgi_module (shared)
python_module (shared)
rewrite_module (shared)
setenvif_module (shared)
socache_shmcb_module (shared)
ssl_module (shared)
status_module (shared)
suexec_module (shared)
userdir_module (shared)
 
Hi theWoosh,

you have missing ( additional ) apache-module - packages on your server:

proxy_module (shared)
proxy_fcgi_module (shared)
should be:
Code:
 proxy_module (shared)
 proxy_fcgi_module (shared)
 proxy_html_module (shared)
 proxy_http_module (shared)
 
Hi theWoosh,

first, pls. make sure, that you included as well

Code:
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
( not only ".html" ! )



If this doesn't already solved your issues, pls. consider to add ALL configuration files ( from /var/www/vhosts/system/YOUR-DOMAIN.COM/conf ) as attachments for further investigations and pls. include as well "/etc/apache2/apache2.conf" + "/etc/apache2/plesk.conf.d/server.conf".
 
Ok - the problem is not with .php files, only with .html files that ocntain php.
But I couldn't see the FCGIWrapper line anywhere so I added an FCGIWrapper line so my vhost.conf file now includes this:

#PHP is running as a FastCGI application
<IfModule mod_fcgid.c>
<Files ~ (\.html)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .html
Options +ExecCGI
allow from all
</Files>
</IfModule>

... unfortunately it still doesn't work when I switch to fastCGI on either 5.5. or 5.6... BTW should this work for FPM as well?

I attach the conf files as requested. Thanks for your help UFHH01!
 

Attachments

  • vhost_conf.zip
    10.2 KB · Views: 2
Hi Rafael - I already have that enabled in vhost.conf...
Hi UFHH01 - Thanks - could you be more specific where the problem might be with the conf files? Many Thanks
 
This thread is marked Resolved but I didn't see the OP say he had gotten it working.

I have exactly the same issue now. Plesk Onyx, Version 17.5.3 Update #6, last updated on May 26, 2017 03:33 AM. PHP version "5.4.16 by OS vendor"; running PHP as FastCGI (but as FPM fails the same way): PHP is not parsing .html files.

/var/www/vhosts/system/MYDOMAIN/conf/vhost.conf contains:

<IfModule mod_fcgid.c>
<Files ~ (\.html)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .html
</Files>
</IfModule>

What to do next?
 
Hi KDawson,

pls. let's investigate your root cause from the start and not from the middle:

If you desire help from the Plesk community, you should consider to provide the following informations:

YOUR current operating system
YOUR current Plesk version
( incl. #MU )

This informations could be displayed easily by using the command "plesk version" over your command line as user "root" over SSH. ;)


Next, it is always wise to inform us about your webserver configuration:

Are you using the combination "apache + nginx" ?

IF you use the combination "apache + nginx", pls. make sure to inform us about your settings at:

=> HOME > Subscriptions > YOUR-DOMAIN.COM > Apache & nginx Settings

Pls. consider to post the WHOLE configuration file(s), so that we are able to investigate your issue together with you ( i.e. "/var/www/vhosts/system/YOUR-DOMAIN.COM/conf/httpd_ip_default.conf" or "httpd.conf" ), because the configuration files "vhosts.conf" and "vhosts_ssl.conf" are only additional apache - configuration files, while the other ones are your basic, domain - specific apache configuration files. ;)

 
Yes, my system uses nginx+apache. I have not changed any of the default values: MIME tyes, Handlers, Deny access to the site, and Index files all have the value "Default"; Proxy mode and Smart static files processing are checked. Additional directives for HTTP shows exactly the contents of vhost.conf. The Plesk & CentOS versions are below, along with vhost.conf and httpd.conf, sanitized for anonymity.

__________

# 510 > plesk version
Product version: Plesk Onyx 17.5.3 Update #6
Update date: 2017/05/26 03:33
Build date: 2017/03/17 16:00
OS version: CentOS 7.3.1611
Revision: 55d1b49a272f44666e1920eca8b6e4da449a38cd
Architecture: 64-bit
Wrapper version: 1.2
# 511 >


/var/www/vhosts/system/MYDOMAIN/conf/vhost.conf:
__________

<Directory /var/www/vhosts/MYDOMAIN/httpdocs>

<IfModule mod_fcgid.c>
<Files ~ (\.html)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .html
</Files>
</IfModule>

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

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

Order allow,deny
Allow from all

</Directory>
__________


/var/www/vhosts/system/MYDOMAIN/conf/httpd.conf:
__________

#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
#IF YOU REQUIRE TO APPLY CUSTOM MODIFICATIONS, PERFORM THEM IN THE FOLLOWING FILES:
#/var/www/vhosts/system/MYDOMAIN/conf/vhost.conf
#/var/www/vhosts/system/MYDOMAIN/conf/vhost_ssl.conf
<IfModule mod_ssl.c>

<VirtualHost 67.207.90.244:7081 >
ServerName "MYDOMAIN:443"
ServerAlias "www.MYDOMAIN"
ServerAlias "ipv4.MYDOMAIN"
ServerAdmin "MYEMAIL"
UseCanonicalName Off

DocumentRoot "/var/www/vhosts/MYDOMAIN/httpdocs"
CustomLog /var/www/vhosts/system/MYDOMAIN/logs/access_ssl_log plesklog
ErrorLog "/var/www/vhosts/system/MYDOMAIN/logs/error_log"

<IfModule mod_suexec.c>
SuexecUserGroup "MYUID" "psacln"
</IfModule>

<IfModule mod_userdir.c>

UserDir "/var/www/vhosts/MYDOMAIN/web_users/*"
</IfModule>

<IfModule mod_sysenv.c>
SetSysEnv PP_VHOST_ID "b0426bac-4082-4ac4-b3ac-53a6c93cf36e"
</IfModule>

Alias "/plesk-stat" "/var/www/vhosts/system/MYDOMAIN/statistics"
<Location /plesk-stat/>
Options +Indexes
</Location>
<Location /plesk-stat/logs/>
Require valid-user
</Location>
Alias /webstat /var/www/vhosts/system/MYDOMAIN/statistics/webstat
Alias /webstat-ssl /var/www/vhosts/system/MYDOMAIN/statistics/webstat-ssl
Alias /ftpstat /var/www/vhosts/system/MYDOMAIN/statistics/ftpstat
Alias /anon_ftpstat /var/www/vhosts/system/MYDOMAIN/statistics/anon_ftpstat
Alias /awstats-icon /var/www/html/awstats/icon

SSLEngine on
SSLVerifyClient none
SSLCertificateFile /usr/local/psa/var/certificates/cert-FbPpdK
SSLCACertificateFile /usr/local/psa/var/certificates/cert-CUWyFG

<Directory /var/www/vhosts/MYDOMAIN/httpdocs>

<IfModule mod_fcgid.c>
<Files ~ (\.fcgi$)>
SetHandler fcgid-script
Options +ExecCGI
</Files>
</IfModule>
<IfModule mod_proxy_fcgi.c>
<Files ~ (\.php$)>
SetHandler proxy:unix:///var/www/vhosts/system/MYDOMAIN/php-fpm.sock|fcgi://127.0.0.1:9000
</Files>
</IfModule>

SSLRequireSSL

Options +Includes -ExecCGI

</Directory>

<Directory "/var/www/vhosts/system/MYDOMAIN/statistics">
AuthType Basic
AuthName "Domain statistics"
AuthUserFile "/var/www/vhosts/system/MYDOMAIN/pd/d..httpdocs@plesk-stat"
require valid-user
</Directory>

Alias /error_docs /var/www/vhosts/MYDOMAIN/error_docs
ErrorDocument 400 /error_docs/bad_request.html
ErrorDocument 401 /error_docs/unauthorized.html
ErrorDocument 403 /error_docs/forbidden.html
ErrorDocument 404 /error_docs/not_found.html
ErrorDocument 500 /error_docs/internal_server_error.html
ErrorDocument 405 /error_docs/method_not_allowed.html
ErrorDocument 406 /error_docs/not_acceptable.html
ErrorDocument 407 /error_docs/proxy_authentication_required.html
ErrorDocument 412 /error_docs/precondition_failed.html
ErrorDocument 414 /error_docs/request_uri_too_long.html
ErrorDocument 415 /error_docs/unsupported_media_type.html
ErrorDocument 501 /error_docs/not_implemented.html
ErrorDocument 502 /error_docs/bad_gateway.html
ErrorDocument 503 /error_docs/maintenance.html

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.MYDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ https://MYDOMAIN$1 [L,R=301]
</IfModule>

<Directory /var/www/vhosts/MYDOMAIN>
AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,SymLinksIfOwnerMatch,MultiViews,FollowSymLinks,ExecCGI,Includes,IncludesNOEXEC
</Directory>

</VirtualHost>

</IfModule>

<VirtualHost 67.207.90.244:7080 >
ServerName "MYDOMAIN:80"
ServerAlias "www.MYDOMAIN"
ServerAlias "ipv4.MYDOMAIN"
ServerAdmin "MYEMAIL"
UseCanonicalName Off

DocumentRoot "/var/www/vhosts/MYDOMAIN/httpdocs"
CustomLog /var/www/vhosts/system/MYDOMAIN/logs/access_log plesklog
ErrorLog "/var/www/vhosts/system/MYDOMAIN/logs/error_log"

<IfModule mod_suexec.c>
SuexecUserGroup "MYUID" "psacln"
</IfModule>

<IfModule mod_userdir.c>

UserDir "/var/www/vhosts/MYDOMAIN/web_users/*"
</IfModule>

<IfModule mod_sysenv.c>
SetSysEnv PP_VHOST_ID "b0426bac-4082-4ac4-b3ac-53a6c93cf36e"
</IfModule>

Redirect permanent /plesk-stat https://MYDOMAIN/plesk-stat
Redirect permanent /webstat https://MYDOMAIN/webstat
Redirect permanent /webstat-ssl https://MYDOMAIN/webstat-ssl
Redirect permanent /ftpstat https://MYDOMAIN/ftpstat
Redirect permanent /anon_ftpstat https://MYDOMAIN/anon_ftpstat
Redirect permanent /awstats-icon https://MYDOMAIN/awstats-icon

<IfModule mod_ssl.c>
SSLEngine off
</IfModule>

<Directory /var/www/vhosts/MYDOMAIN/httpdocs>

<IfModule mod_fcgid.c>
<Files ~ (\.fcgi$)>
SetHandler fcgid-script
Options +ExecCGI
</Files>
</IfModule>
<IfModule mod_proxy_fcgi.c>
<Files ~ (\.php$)>
SetHandler proxy:unix:///var/www/vhosts/system/MYDOMAIN/php-fpm.sock|fcgi://127.0.0.1:9000
</Files>
</IfModule>

Options +Includes -ExecCGI

</Directory>

<Directory "/var/www/vhosts/system/MYDOMAIN/statistics">
AuthType Basic
AuthName "Domain statistics"
AuthUserFile "/var/www/vhosts/system/MYDOMAIN/pd/d..httpdocs@plesk-stat"
require valid-user
</Directory>

Alias /error_docs /var/www/vhosts/MYDOMAIN/error_docs
ErrorDocument 400 /error_docs/bad_request.html
ErrorDocument 401 /error_docs/unauthorized.html
ErrorDocument 403 /error_docs/forbidden.html
ErrorDocument 404 /error_docs/not_found.html
ErrorDocument 500 /error_docs/internal_server_error.html
ErrorDocument 405 /error_docs/method_not_allowed.html
ErrorDocument 406 /error_docs/not_acceptable.html
ErrorDocument 407 /error_docs/proxy_authentication_required.html
ErrorDocument 412 /error_docs/precondition_failed.html
ErrorDocument 414 /error_docs/request_uri_too_long.html
ErrorDocument 415 /error_docs/unsupported_media_type.html
ErrorDocument 501 /error_docs/not_implemented.html
ErrorDocument 502 /error_docs/bad_gateway.html
ErrorDocument 503 /error_docs/maintenance.html

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.MYDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ http://MYDOMAIN$1 [L,R=301]
</IfModule>

Include "/var/www/vhosts/system/MYDOMAIN/conf/vhost.conf"

<Directory /var/www/vhosts/MYDOMAIN>
AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,SymLinksIfOwnerMatch,MultiViews,FollowSymLinks,ExecCGI,Includes,IncludesNOEXEC
</Directory>

</VirtualHost>
__________
 
Hi KDawson,

<IfModule mod_fcgid.c>
<Files ~ (\.html)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .html
</Files>
</IfModule>


The correct usage would be for apache version > 2.4:
Code:
<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>

...while apache versions up to 2.2 needs the following configuration:
Code:
<IfModule mod_fcgid.c>
    <Files ~ (\.html)>
        SetHandler fcgid-script
        FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .html
        Options +ExecCGI
        Order allow,deny
        Allow from all
    </Files>
</IfModule>
 
Thank you.

But no change. PHP is not parsing HTML files. A directive such as <? include("test.html") ?> is ignored.
 
Last edited:
Hi KDawson,

pls. consider to inspect your domain - specific log - files, in order to find your root cause, because this will mostly point you directly to any possible misconfiguration.

If you desire more help, you should consider to provide the URL, so that people willing to help you have the chance to investigate possible issues/errors/problems and might point you to individual solutions/work-arounds or coding mistakes. :)
 
Back
Top