Apache downloads the PHP files instead of executing them in FCGId mode

New virtualmin installation on fresh CentOS 7 minimal install

virtualmin check-config

Your system has 11.73 GB of memory, which is at or above the Virtualmin recommended minimum of 256 MB.

BIND DNS server is installed, and the system is configured to use it.

Mail server Postfix is installed and configured.

Postfix is configured to support per-domain outgoing IP addresses.

Apache is installed.

The following PHP versions are available : 5.4.16 (/bin/php-cgi), 7.2.10 (/opt/rh/rh-php72/root/usr/bin/php-cgi), 5.4 (mod_php)

The following PHP-FPM versions are available on this system : 5.4.16 7.2.10

Webalizer is installed.

Apache is configured to host SSL websites.

MySQL is installed and running.

ProFTPD is installed.

Logrotate is installed.

SpamAssassin and Procmail are installed and configured for use.

ClamAV is installed and assumed to be running.

The System and Server Status module is installed and checking on schedule.

Plugin AWstats reporting is installed OK.

Plugin DAV Login is installed OK.

Plugin Protected web directories is installed OK.

Using network interface ens192 for virtual IPs.

IPv6 addresses are available, using interface ens192.

Default IPv4 address for virtual servers is

Default IPv6 address for virtual servers is

Quotas are not enabled on the filesystem /home which contains home directories under /home and email files under /home. Quota editing has been di                                sabled.

All commands needed to create and restore backups are installed.

Resource limits are supported and configured correctly.

The selected package management and update systems are installed OK.

Chroot jails are available on this system

The Virtualmin YUM repository is configured correctly

OK

cat /etc/httpd/conf.d/php.conf

#
# Cause the PHP interpreter to handle files with a .php extension.
#
#<FilesMatch \.php$>
#    SetHandler application/x-httpd-php
#</FilesMatch>
#
#
# Allow php to handle Multiviews
#
#AddType text/html .php
#
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
#DirectoryIndex index.php
#
#
# Uncomment the following lines to allow PHP to pretty-print .phps
# files as PHP source code:
#
#<FilesMatch \.phps$>
#    SetHandler application/x-httpd-php-source
#</FilesMatch>
#
#
# Apache specific PHP configuration options
# those can be override in each configured vhost
#
#php_value session.save_handler "files"
#php_value session.save_path    "/var/lib/php/session"

virtual host:

<VirtualHost 10.10.10.85:443 [fe80::250:56ff:fe92:acff]:443>
SuexecUserGroup "#1000" "#1000"
ServerName web2.some.tld
ServerAlias www.web2.some.tld
ServerAlias mail.web2.some.tld
ServerAlias webmail.web2.some.tld
ServerAlias admin.web2.some.tld
DocumentRoot /home/web2/public_html
ErrorLog /var/log/virtualmin/web2.some.tld_error_log
CustomLog /var/log/virtualmin/web2.some.tld_access_log combined
ScriptAlias /cgi-bin/ /home/web2/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/web2/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
AddHandler fcgid-script .php7.2
FCGIWrapper /home/web2/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/web2/fcgi-bin/php5.fcgi .php5
FCGIWrapper /home/web2/fcgi-bin/php7.2.fcgi .php7.2
</Directory>
<Directory /home/web2/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.web2.some.tld
RewriteRule ^(.*) https://web2.some.tld:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.web2.some.tld
RewriteRule ^(.*) https://web2.some.tld:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php7.2
php_admin_value engine Off
SSLEngine on
SSLCertificateFile /home/web2/ssl.cert
SSLCertificateKeyFile /home/web2/ssl.key
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCACertificateFile /home/web2/ssl.ca
FcgidMaxRequestLen 1073741824
IPCCommTimeout 31
</VirtualHost>
Status: 
Active

Comments

I've tried these steps already ...

find /etc/httpd -type f | xargs grep -i sethandler
/etc/httpd/conf.d/php.conf:#    SetHandler application/x-httpd-php
/etc/httpd/conf.d/php.conf:#    SetHandler application/x-httpd-php-source

both occurances are commented out

Hmm, I was expecting to see SetHandler lines from other config files... are those really the only two you're seeing though?

Also, do you see the same issue with other PHP Execution Modes, such as CGI?

What if you change the PHP version, does that change things?

These are the only I can find

Changing PHP Version does not change behavior

Changing Execution Mode to FPM does not change behavior

Changing PHP execution mode to FPM (run as virtual server owner) ..
.. done

Changing maximum PHP script run time to 30 seconds ..
.. done

Restarting PHP-FPM server ..
.. done

Applying web server configuration ..
.. done

Hmm, what is the output of this command:

rpm -qa | grep php

Also, I don't imagine restarting Apache helps does it?

rpm -qa | grep php

output

php-process-5.4.16-46.el7.x86_64
php-fpm-5.4.16-46.el7.x86_64
rh-php72-php-common-7.2.10-3.el7.x86_64
rh-php72-php-pear-1.10.5-1.el7.noarch
rh-php72-php-xmlrpc-7.2.10-3.el7.x86_64
rh-php72-php-mbstring-7.2.10-3.el7.x86_64
php-xml-5.4.16-46.el7.x86_64
php-5.4.16-46.el7.x86_64
php-xmlrpc-5.4.16-46.el7.x86_64
rh-php72-runtime-1-2.el7.x86_64
rh-php72-php-cli-7.2.10-3.el7.x86_64
rh-php72-php-pdo-7.2.10-3.el7.x86_64
rh-php72-php-devel-7.2.10-3.el7.x86_64
rh-php72-php-gd-7.2.10-3.el7.x86_64
php-cli-5.4.16-46.el7.x86_64
php-gd-5.4.16-46.el7.x86_64
php-pear-1.9.4-21.el7.noarch
php-imap-5.4.16-9.el7.x86_64
rh-php72-php-json-7.2.10-3.el7.x86_64
rh-php72-php-xml-7.2.10-3.el7.x86_64
rh-php72-php-mysqlnd-7.2.10-3.el7.x86_64
rh-php72-php-bcmath-7.2.10-3.el7.x86_64
rh-php72-php-opcache-7.2.10-3.el7.x86_64
php-common-5.4.16-46.el7.x86_64
php-pdo-5.4.16-46.el7.x86_64
php-mysql-5.4.16-46.el7.x86_64
php-mbstring-5.4.16-46.el7.x86_64
rh-php72-php-zip-7.2.10-3.el7.x86_64
rh-php72-php-process-7.2.10-3.el7.x86_64
rh-php72-1-2.el7.x86_64
wbm-php-pear-1.6-1.noarch
rh-php72-php-pspell-7.2.10-3.el7.x86_64
rh-php72-php-fpm-7.2.10-3.el7.x86_64

apache restart does not fix it ;)

Kvark's picture
Submitted by Kvark on Mon, 07/15/2019 - 18:41

got same issue after virtualmin update, something is messing with php - as was able to fix only then remove all php and reinstall them back