Migrating servers - php fcgi breaks after importing virtualmin domain backup

5 posts / 0 new
Last post
#1 Fri, 11/08/2019 - 16:43
h2ojunkie

Migrating servers - php fcgi breaks after importing virtualmin domain backup

The dreaded "end of script headers before output" error that will not end!

I've been racking my brain for over week on this, I'm not even sure where to start listing everything I've tried (I've tried A LOT).

I'm migrating to new servers. The old servers were: CentOS Linux 7.7.1908 Webmin 1.932 Usermin 1.780 Virtualmin 6.08

New servers are the same.

The only significant difference, is the old servers had more versions of php installed (5.4, 5.5, 5.6, 7.0, 7.1, 7.2). And the new servers are using Apache MPM event, the old servers used MPM worker. I did try using MPM worker as well. However, if I add new virtual domains to the server BEFORE I restore any domains from backup, those newly created domains work without issue.

The new servers have only 5.4, 7.0 and 7.2. However the domains I'm importing only use 7.2 or 7.0, so that shouldn't be an issue.

I've tried importing virtualmin config settings first, no luck, I've tried manually configuring before import, no luck.

When I do the import, the only error I get is regarding let's encrypt no longer supporting v1 client, so I manually add a self sign cert after import. And that appears to work.

Virtualmin re-check config shows the same both before and after importing the domain backup. (all passes, with the expected php versions shown). Validate virtual servers also passes without errors.

If I enable php-fpm for the domain, all 3 versions work. If I enable mod_php, that also works. However, if I try to use fcgi, or even cgi, I get the dreaded error. And for the life of me, I can not figure out why.

The real insanity here, is I migrated two servers. The first one is working perfectly, however I migrated that server at the beginning of October, when the webmin/virtualmin version was 1930/6.07. That first server works without any issues, even after being updated to 1.932 and 6.08

Virtualmin Config Check:

The status of your system is being checked to ensure that all enabled features are available, that the mail server is properly configured, and that quotas are active ..
Your system has 31.26 GB of memory, which is at or above the Virtualmin recommended minimum of 256 MB.
Apache is installed.

The following PHP versions are available : 5.4.45 (/bin/php-cgi), 7.0.33 (/bin/php70-cgi), 7.2.24 (/bin/php72-cgi), 5.4 (mod_php)

The following PHP-FPM versions are available on this system : 5.4.45 (php-fpm) 7.0.33 (php70-php-fpm) 7.2.24 (php72-php-fpm)

Apache is configured to host SSL websites.

MariaDB 10.3.20 is installed and running.

Logrotate is installed.

Plugin Protected web directories is installed OK.

Using network interface eth0 for virtual IPs.

IPv6 addresses are available, using interface eth0.

Default IPv4 address for virtual servers is XXXXXX.

Default IPv6 address for virtual servers is XXXXXX.

Both user and group quotas are enabled for home and email directories.

All commands needed to create and restore backups are installed.

The selected package management and update systems are installed OK.

Chroot jails are available on this system

.. your system is ready for use by Virtualmin.

Apache Config

SuexecUserGroup "#1002" "#1002"
ServerName test.domain
ServerAlias www.test.domain
DocumentRoot /home/test.domain/public_html
ErrorLog /var/log/virtualmin/test.domain_error_log
CustomLog /var/log/virtualmin/test.domain_access_log combined
ScriptAlias /cgi-bin/ /home/test.domain/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/test.domain/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.0
AddHandler fcgid-script .php7.2
FCGIWrapper /home/test.domain/fcgi-bin/php7.2.fcgi .php
FCGIWrapper /home/test.domain/fcgi-bin/php5.fcgi .php5
FCGIWrapper /home/test.domain/fcgi-bin/php7.0.fcgi .php7.0
FCGIWrapper /home/test.domain/fcgi-bin/php7.2.fcgi .php7.2
</Directory>
<Directory /home/test.domain/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php7.0
RemoveHandler .php7.2
php_admin_value engine Off
IPCCommTimeout 121
FcgidMaxRequestLen 1073741824

I've check owner:group permissions. I've disabled suex just to be sure that's not involved. And i can not for the life of me figure out what I'm missing.

Any suggestions are appreciated. If there's any additional info needed, just let me know what I need ot provide.

Fri, 11/08/2019 - 16:53
Dibs

If I enable php-fpm for the domain, all 3 versions work. If I enable mod_php

IIRC - mod_php only works well with Apache’s Prefork MPM no Worker or Event. - https://medium.com/@jacksonpauls/moving-from-mod-php-to-php-fpm-914125a7...

Fri, 11/08/2019 - 17:18
h2ojunkie

mod_php works fine. it's fcgi that's the problem.

Fri, 11/08/2019 - 18:40
briand

can you try changing the php mode in website options, change to CGI wrapper, then change it back again Brian

PHP script execution mode
Apache mod_php (run as Apache's user) CGI wrapper (run as virtual server owner) FCGId (run as virtual server owner) FPM (run as virtual server owner)

Fri, 11/08/2019 - 19:02
h2ojunkie

Thanks. I did try that. Neither CGI or FCGI work. This seems like some type of server configuration issue. But I just can’t figure out what that issue is.

I’m really confused by the fact that FPM works. I would think if FCGI has a problem, fpm couldn’t work either