Upgraded from Ubuntu 16.04 to 18.04 and Apache and PHP 7.2 not working properly

SYSTEM INFORMATION
OS type and version: Ubuntu 18.04
Webmin version: 1.984
Virtualmin version: 6.17-3
Related products version: PHP 7.2

Hi all,
I upgraded my server from Ubuntu 16.04 to 18.04 and PHP 7.0 to 7.2 and I have the following problems:

PHP running as FCGI does not work, the php file is not processed and the source is sent to the browser.

PHP running as mod_php works only on https, on http the source file is sent to the browser.

I have reviewd the apache2 configuration files, and spent the last 2 days searching the Internet and nothing that I’ve found has solved the problem.

There are no errors on the apache log files, but there is one strange observation, there are no entries on the apache suexec.log which means that apache is not even trying tu run the php7.2.fcgi under fcgi-bin

Any help would be greatly appreciated.

Here are two virtual sites’ configuration files

PHP on FCGI

<VirtualHost *:80>
SuexecUserGroup “#1001” “#1001”

ServerName chat.zigue.mx
ServerAlias www.chat.zigue.mx
ServerAlias webmail.chat.zigue.mx
ServerAlias admin.chat.zigue.mx

DocumentRoot /home/zigue/domains/chat.zigue.mx/public_html

ErrorLog /var/log/virtualmin/chat.zigue.mx_error_log
CustomLog /var/log/virtualmin/chat.zigue.mx_access_log combined

ScriptAlias /cgi-bin/ /home/zigue/domains/chat.zigue.mx/cgi-bin/
ScriptAlias /awstats/ /home/zigue/domains/chat.zigue.mx/cgi-bin/

DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/zigue/domains/chat.zigue.mx/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 .php7.2
    FCGIWrapper /home/zigue/domains/chat.zigue.mx/fcgi-bin/php7.2.fcgi .php
    FCGIWrapper /home/zigue/domains/chat.zigue.mx/fcgi-bin/php7.2.fcgi .php7.2
</Directory>

<Directory /home/zigue/domains/chat.zigue.mx/cgi-bin>
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
</Directory>

RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.chat.zigue.mx
RewriteRule ^(.*) https://chat.zigue.mx:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.chat.zigue.mx
RewriteRule ^(.*) http://chat.zigue.mx:10000/ [R]
RemoveHandler .php
RemoveHandler .php7.2
php_admin_value engine Off

FcgidMaxRequestLen 1073741824

<Files awstats.pl>
    AuthName "app.zigue.mx statistics"
    AuthType Basic
    AuthUserFile /home/zigue/domains/chat.zigue.mx/.awstats-htpasswd
    require valid-user
</Files>
IPCCommTimeout 31
RedirectMatch /(.*)$ https://chat.zigue.mx

<VirtualHost *:443>
SuexecUserGroup “#1001” “#1001”

ServerName chat.zigue.mx
ServerAlias www.chat.zigue.mx
ServerAlias webmail.chat.zigue.mx
ServerAlias admin.chat.zigue.mx

DocumentRoot /home/zigue/domains/chat.zigue.mx/public_html

ErrorLog /var/log/virtualmin/chat.zigue.mx_error_log
CustomLog /var/log/virtualmin/chat.zigue.mx_access_log combined

ScriptAlias /cgi-bin/ /home/zigue/domains/chat.zigue.mx/cgi-bin/
ScriptAlias /awstats/ /home/zigue/domains/chat.zigue.mx/cgi-bin/

DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/zigue/domains/chat.zigue.mx/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 .php7.2
    FCGIWrapper /home/zigue/domains/chat.zigue.mx/fcgi-bin/php7.2.fcgi .php
    FCGIWrapper /home/zigue/domains/chat.zigue.mx/fcgi-bin/php7.2.fcgi .php7.2
</Directory>

<Directory /home/zigue/domains/chat.zigue.mx/cgi-bin>
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
</Directory>

RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.chat.zigue.mx
RewriteRule ^(.*) https://chat.zigue.mx:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.chat.zigue.mx
RewriteRule ^(.*) http://chat.zigue.mx:10000/ [R]
RemoveHandler .php
RemoveHandler .php7.2
php_admin_value engine Off

FcgidMaxRequestLen 1073741824

<Files awstats.pl>
    AuthName "app.zigue.mx statistics"
    AuthType Basic
    AuthUserFile /home/zigue/domains/chat.zigue.mx/.awstats-htpasswd
    require valid-user
</Files>

SSLEngine on
SSLCertificateFile /home/zigue/domains/chat.zigue.mx/ssl.cert
SSLCertificateKeyFile /home/zigue/domains/chat.zigue.mx/ssl.key
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCACertificateFile /home/zigue/domains/chat.zigue.mx/ssl.ca
IPCCommTimeout 31

PHP on mod_php

<VirtualHost *:80>
SuexecUserGroup “#1001” “#1001”

ServerName app.zigue.mx
ServerAlias www.app.zigue.mx
ServerAlias webmail.app.zigue.mx
ServerAlias admin.app.zigue.mx

DocumentRoot /home/zigue/domains/app.zigue.mx/public_html

ErrorLog /var/log/virtualmin/app.zigue.mx_error_log
CustomLog /var/log/virtualmin/app.zigue.mx_access_log combined

ScriptAlias /cgi-bin/ /home/zigue/domains/app.zigue.mx/cgi-bin/
ScriptAlias /awstats/ /home/zigue/domains/app.zigue.mx/cgi-bin/

DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/zigue/domains/app.zigue.mx/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-php7.2 .php7.2
    AddType application/x-httpd-php .php
</Directory>

<Directory /home/zigue/domains/app.zigue.mx/cgi-bin>
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
</Directory>

RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.app.zigue.mx
RewriteRule ^(.*) https://app.zigue.mx:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.app.zigue.mx
RewriteRule ^(.*) http://app.zigue.mx:10000/ [R]

<Files awstats.pl>
    AuthName "app.zigue.mx statistics"
    AuthType Basic
    AuthUserFile /home/zigue/domains/app.zigue.mx/.awstats-htpasswd
    require valid-user
</Files>
RedirectMatch /(.*)$ https://app.zigue.mx

<VirtualHost *:443>
SuexecUserGroup “#1001” “#1001”

ServerName app.zigue.mx
ServerAlias www.app.zigue.mx
ServerAlias webmail.app.zigue.mx
ServerAlias admin.app.zigue.mx

DocumentRoot /home/zigue/domains/app.zigue.mx/public_html

ErrorLog /var/log/virtualmin/app.zigue.mx_error_log
CustomLog /var/log/virtualmin/app.zigue.mx_access_log combined

ScriptAlias /cgi-bin/ /home/zigue/domains/app.zigue.mx/cgi-bin/
ScriptAlias /awstats/ /home/zigue/domains/app.zigue.mx/cgi-bin/

DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/zigue/domains/app.zigue.mx/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-php7.2 .php7.2
    AddType application/x-httpd-php .php
</Directory>

<Directory /home/zigue/domains/app.zigue.mx/cgi-bin>
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
</Directory>

RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.app.zigue.mx
RewriteRule ^(.*) https://app.zigue.mx:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.app.zigue.mx
RewriteRule ^(.*) http://app.zigue.mx:10000/ [R]

<Files awstats.pl>
    AuthName "app.zigue.mx statistics"
    AuthType Basic
    AuthUserFile /home/zigue/domains/app.zigue.mx/.awstats-htpasswd
    require valid-user
</Files>

SSLEngine on
SSLCertificateFile /home/zigue/domains/app.zigue.mx/ssl.cert
SSLCertificateKeyFile /home/zigue/domains/app.zigue.mx/ssl.key
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCACertificateFile /home/zigue/domains/app.zigue.mx/ssl.ca

That thundering sound you’re hearing is @Joe stomping towards his keyboard coming to tell you that you should never, ever, under any circumstances install mod php on your system.

It breaks the hell out of a lot of things.

3 Likes

also 16.04 was Apache 2.2 and 18.04 was on Apache 2.4 if I remember correctly which means some changes in Apaches congratulations, it wouldn’t work whatever PHP mode he is using without altering old congratulation or setups even htaccess changed a bits and bobs… you will have to go site by site and find out what’s the problem.

1 Like

Thanks, at the momement mod_php is the only thing that has my sites more or less working!

Yes, I realized that and have checked the configuration files but have been unable to find the offending bit

well then best advice from me to you to recover server in fastest possible way, backup your site’s, nuke server and install latest supported Ubuntu version or other os and deploy virtualmin fresh. then restore backups… backups I mean no domain configuration just DBs and files in public html directory and emails if you have any…rest is fast by hand… changes within Apache it self are not small and it can take weeks to fix it…faster would be nuke rather than wasting valuable time :zipper_mouth_face:

Have you run “Re-check Configuration” and “Validate Virtual Servers” since the upgrade? You just changed the whole OS out from under Virtualmin, you need to give it a clue about that change.

But, also, get rid of mod_php. It breaks every execution mode except mod_php.

1 Like

Thanks, I did run Re-check configuration and Validate Virtual Servers with no error reported. I’ll try disabling mod_php completly and see what happens.

The problem with installing mod_php (the php package, usually) is that it installs a config file that adds SetHandlers for PHP files that overrides per-host handlers setup by Virtualmin. You have to remove those handlers, but package changes (upgrades, installing additional PHP versions) can bring those handlers back, as long as dpkg/apt believe you want mod_php, breaking all sites again without warning.

Merely disabling mod_php does not prevent package changes from breaking sites. (But, if you want to test my theory that it’s mod_php that is breaking your sites, you can make sure all those handlers are removed…they’re in the php.conf file in the mods-enabled directory, I think.)

Thanks, I have already checked all config files for SetHandlers and AddHandlers and there are none except for those in per directory configuration (which I had to enable as a last resource to get my sites back on line) I’m wondering if mixing mod_php and FCGI is not possible (Virtualmin does allow it). I will test this tonight.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.