Fixing miscellaneous Webmin SilverStripe errors after a restore

This is mostly a reference post in case I ever have to go through this again. If it helps you too - well I've been there, I feel your pain, hopefully your pain doesn't last as long and you find some answers here.

  • PHP memory_limit (mod_fcgid: stderr: PHP Fatal error:  Allowed memory size of X bytes exhausted in framework/core/Config.php on line 592) - this is probably caused by the cache. In either /tmp or the public_html for the site there will be a cache folder called silverstripe-cache. Just clear it with find silverstripe-cache -type f -delete
  • Webmin PHP version changes don't take effect (ie. you select one version but it's still loading the wrong one). Just go to Website Options and change it site to use cgi, then change it back to fcgi and it should work.
  • Webmin PHP can't be changed to fcgi for a site - this can seemingly be resolved by adding the SuExec to the Apache configuration. grep the user from /etc/passwd eg. example:x:730:584::/home/example:/bin/bash, take the 730:584 and add SuexecUserGroup "#730" "#584" under the <VirtualHost> - make sure you do this for both port 80 and port 443 if both are defined. Restart Apache (not sure if this is necessary) and Webmin should let you use fcgi after that.
  • Fatal error: 'continue' operator with non-constant operand is no longer supported - the server you restored it from was probably running PHP 5.3 (what year is it?) and you're now on PHP 5.4. If 5.3 isn't an option, just find the line it's complaining about, and see if it needs a semicolon at the end.
  • Webmin PHP files are being downloaded instead of executed after a restore - I found the only way to fix this is to add the SuExec per above, and change the <directory /home/blah/public_html> stanza to:
<Directory /home/blah/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 .php5.5
AddHandler fcgid-script .php5.6
AddHandler fcgid-script .php7.0
AddHandler fcgid-script .php7.2
FCGIWrapper /home/blah/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/blah/fcgi-bin/php5.fcgi .php5
FCGIWrapper /home/blah/fcgi-bin/php5.5.fcgi .php5.5
FCGIWrapper /home/blah/fcgi-bin/php5.6.fcgi .php5.6
FCGIWrapper /home/blah/fcgi-bin/php7.0.fcgi .php7.0
FCGIWrapper /home/blah/fcgi-bin/php7.2.fcgi .php7.2

Important - the above FCGIWrappers should match those inside /home/blah/fcgi-bin, so if 5.4 exists but nothing higher does, change the 5.5 line to 5.4, and delete the 5.6, 7.0 and 7.2 lines. The AddHandlers don't seem to cause any problems.

Next add the following right before </VirtualHost>:

RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php5.5
RemoveHandler .php5.6
RemoveHandler .php7.0
RemoveHandler .php7.2
php_admin_value engine Off

Restart Apache, and fingers crossed the site at least gives an error instead of just downloading PHP.

  • A directory says Sorry, there was a problem with handling your request. with no errors in the log - there's a warning in the log isn't there about the timezone. Fix that and it will go away. Add date_default_timezone_set('Europe/London'); to the bottom of framework/_config.php and it should start working (other timezones are available). If it doesn't, add Director::set_environment_type("dev"); to the end of that file instead and refresh.
  • Connection reset by peer: mod_fcgid: error reading data from FastCGI server - try the advice above for rewriting the PHP config and deleting the cache. If that doesn't work, cd into /home/blah/fcgi-bin and run chattr -i *; rm -f *, then cp -a /home/blah/etc/ /home/blah/etc-backup/; find /home/blah/etc/ -type f -delete, go into webmin and switch PHP to cgi and then back to fcgi.