Setting up my new server was going so well with Virtualmin.
The sites were working fine and I’d modified /etc/php5/apache2/php.ini and all was good.
Today I enabled SSL on a couple of sites and set the IP-based virtual FTP on. The SSL seemed to work.
I then added lots of email addresses to a couple of sites.
Suddenly I get nasty issues.
The short of it is that the PHP API Server has changed from “Apache 2 handler” which I was perfectly happy with to “CGI/FastCGI” which is breaking all sorts of stuff. I have no idea how this happened.
I don’t know what the PHPSuexec and the CGI/FastCGI stuff do but I don’t want or need them.
Can you tell me how to get back to the ‘standard’ Apache 2 Handler for the “Server API” under PHP Info?
…and ideally tell me how to avoid falling into this trap again.
Hmm… that shouldn’t change on it’s own, in theory!
You should be able to switch between FCGID, CGI, and mod_php by going into Server Configuration -> Website Options, and setting the “PHP script execution mode” option.
A note about this: Should the Apache mod_php option not appear anymore in the script execution modes list (happened to me a few times during my experiments), that might be due to a disabled PHP 5 mod in Apache, which can be remedied using:
Thanks for the quick replies. I really appreciate the support.
Locutus: As I know I want php5 (and appear to already have it) I tried enabling that first. The restart yielded this:
root@ws1:/etc/php5/apache2# service apache2 restart
* Restarting web server apache2 * We failed to correctly shutdown apache, so we're now killing all running apache processes. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!
... waiting apache2: Syntax error on line 204 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory
This indicates that I never had php5 enabled as a module - not sure what is going on here since phpinfo reports version 5.3.2) so I guessed it cannot be the problem. I disabled the module again.
Eric: On the Website options the execution mode is set to FCGId. Both options say “run as virtual server owner” which I don’t want (explanation below). No other option appears. So:
Changing “Run CGI scripts as domain owner” to “no” (cgi scripts would be OK but NOT the PHP) and gave me an error:
“Failed to save website options : The CGI wrapper option cannot be selected unless Run CGI scripts as domain owner is”
The same error occurs with either attempted execution mode setting.
Just changing the execution mode to “CGI Wrapper” did not make any difference to the problem. I put the option back again.
On to the backups… I’ll post here as I discover more.
Two of the websites use a shared database via the Magento ecommerce system. They have an identical file set with appropriate parameters being set in the .htaccess file.
In order for Magento to work smoothly the public_html folder of one site is simply a link to the public_html folder on the other site. This works well when the apache user is www-data for both sites but falls in a heap if the sites were running scripts as the site owner. Workarounds for this are possible with groups etc. but I’d prefer to simply have it working the way it was.
The error message you posted sounds like the apache module for php 5 is actually missing… Question of course is how it got uninstalled. Or maybe just the module file was deleted.
Assuming you’re using Ubuntu or Debian or another distro with the apt package manager, can you please post the output of
apt-show-versions | grep libapache2
Still assuming that you’re using a distro with “apt”, the following command reinstalls the apache php 5 package, reinstating the libphp5.so file if it got deleted:
apt-get install libapache2-mod-php5 --reinstall
Also, did you install Virtualmin using the automatic installer script? If so, the apache php 5 module would have been auto-installed.
I did auto install.
paul@ws1:~$ apt-show-versions | grep libapache2
libapache2-mod-fcgid/lucid-updates uptodate 1:2.3.4-2ubuntu0.1
libapache2-mod-ruby/lucid uptodate 1.2.6-2
libapache2-svn/lucid uptodate 1.6.6dfsg-2ubuntu1
I’ve reinstalled php5 which is not installed - is it really needed if PHP is there?? the php was working fine on the site without it.
paul@ws1:~$ sudo apt-get install libapache2-mod-php5 --reinstall
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
The following packages will be REMOVED:
The following NEW packages will be installed:
0 upgraded, 2 newly installed, 1 to remove and 14 not upgraded.
Need to get 2,424B/2,836kB of archives.
After this operation, 7,741kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://au.archive.ubuntu.com/ubuntu/ lucid-updates/main apache2-mpm-prefork 2.2.14-5ubuntu8.3 [2,424B]
Fetched 2,424B in 0s (7,316B/s)
dpkg: apache2-mpm-worker: dependency problems, but removing anyway as you requested:
apache2 depends on apache2-mpm-worker (= 2.2.14-5ubuntu8.3) | apache2-mpm-prefork (= 2.2.14-5ubuntu8.3) | apache2-mpm-event (= 2.2.14-5ubuntu8.3) | apache2-mpm-itk (= 2.2.14-5ubuntu8.3); however:
Package apache2-mpm-worker is to be removed.
Package apache2-mpm-prefork is not installed.
Package apache2-mpm-event is not installed.
Package apache2-mpm-itk is not installed.
(Reading database ... 102470 files and directories currently installed.)
Removing apache2-mpm-worker ...
* Stopping web server apache2 ... waiting [ OK ]
Selecting previously deselected package apache2-mpm-prefork.
(Reading database ... 102465 files and directories currently installed.)
Unpacking apache2-mpm-prefork (from .../apache2-mpm-prefork_2.2.14-5ubuntu8.3_i386.deb) ...
Selecting previously deselected package libapache2-mod-php5.
Unpacking libapache2-mod-php5 (from .../libapache2-mod-php5_5.3.2-1ubuntu4.5_i386.deb) ...
Setting up apache2-mpm-prefork (2.2.14-5ubuntu8.3) ...
* Starting web server apache2 [ OK ]
Setting up libapache2-mod-php5 (5.3.2-1ubuntu4.5) ...
* Reloading web server config apache2 [ OK ]
Now the sites are totally broken and PHP is not working at all!
To clarify ‘broken’ further the php extension is not being recognised so I get prompted to download the file on a browser.
When I restarted apache again, I got the mod_php execution mode option back again for executing php scripts. I’m very confused - why would the second restart make any difference?
I set the sites how they should be (Apache 2 handler and no running CGI scripts as the domain owner…
PHP reports the right thing. The sites work again - including the linked one.
I’m still confused but its all working again.
It seems php5 had gone missing.
Thanks for the help.
Thank you so much for this post!
I want to report that I have experienced exactly the same problem as whippy.
I use “Ubuntu” as well.
The solution given here worked for me too.
It is really not normal that php5 disappeared this way.
So there must have been some bug whether in Virtualmin or in Ubuntu coming from a recent “apt-get update”.
Same here - after installing updates, apache refused to start - complaining of syntax errors in site config files -
Invalid command ‘php_value’, perhaps misspelled or defined by a module not included in the server configuration
after an apt-get update
apt-get install libapache2-mod-php5 --reinstall
apache now restarts and things ‘look’ like they are working again.