mod_php sites do not migrate properly

When migrating several sites from a VM GPL installation that was initially set up in late 2007 none of these sites could be restored using their original mod_php Server API causing some of these scripts to not function properly but more importantly no longer get cached by eAccelerator or other php caching scripts.(xcache).

When restoring the message appeared: "Checking restored PHP execution mode .. .. mode Apache mod_php cannot be used, switching to FCGId."

I was able to fix this for all the sites manually.

Finally in Virtualmin under 'Website Options' there are only two options for 'PHP script execution mode': CGI wrapper and FCGId and this has always been the case since the first install and when creating new sites. After the manual changes however neither of these options are now selected(blank radio buttons).

Status: 
Active

Comments

Joe's picture
Submitted by Joe on Wed, 09/29/2010 - 03:55 Pro Licensee

The lack of a mod_php option means that mod_php is not enabled in your Apache configuration. I'm surprised that's so if this is a stock CentOS 5 install, as I seem to recall installing the PHP packages enables mod_php.

Do you have an /etc/httpd/conf.d/php.conf file?

Was Apache, perchance, already installed and configured when you ran the Virtualmin install script? Sometimes having existing configuration changes can cause RPM to not run postinstall scripts or to not replace config files.

Yes Apache was already installed before installing virtualmin. I don't recall the instructions making light of uninstalling apache before installing Virtualmin but I don't recall exactly. This all makes sense now though.

Yes I have /etc/httpd/conf.d/php.conf . After making some changes to httpd.conf I was able to get my sites to run under mod_php... Well I think so. It shows up in phpinfo() after the changes. Server API changed from CGI/FastCGI to Apache 2.0 Handler as well.

I deleted these lines from httpd.conf for each site after which eAccelerator started working and Server API changed:

Action application/x-httpd-php5 /cgi-bin/php5.cgi AddType application/x-httpd-php5 .php5 AddType application/x-httpd-php5 .php

RemoveHandler .php RemoveHandler .php5

and here is the php.conf:

#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#

LoadModule php5_module modules/libphp5.so

# Use of the "ZTS" build with worker is experimental, and no shared
# modules are supported.
LoadModule php5_module modules/libphp5-zts.so

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
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 line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps

Any advice to make sure Virtualmin is set up properly on this system ? I prefer not to wipe out and start over :)

Joe's picture
Submitted by Joe on Fri, 10/01/2010 - 10:17 Pro Licensee

Apache being already installed shouldn't have been a problem, but if it had any configuration changes, then RPM will not replace configuration files or alter them.

Manual changes to the configuration of your virtual servers should not be required (and may confuse Virtualmin, though most types of command line changes are comprehended by Virtualmin, in this case there's a lot of room for differences that might cause it to not understand what's happening). Once mod_php is enabled, Virtualmin should offer you the option to enable it for your virtual hosts (and restoring backups of servers that use mod_php should restore without error). You'll need to do a "Re-check Config" in System Settings to make Virtualmin aware of the change.