.php5 files are executed by .fcgid, .php files are not in Virtualmin Pro

After installing Virtualmin we found that .php files were not being run through fcgid and so are running as the apache user & group rather than the virtual server user & group that they should be. Interestingly .php5 files ARE being run by fcgid as expected. This is a straightforward install Ubuntu 10.04, run Install.sh & enjoy setup. What should be mentioned as well is that this is a migration from a CentOS 5 system where everything was working as expected.

Here are examples of the issue:

As you can see they're being handled completely differently.

Here's the site configuration:

SuexecUserGroup #1002 #1002
ServerName molybdenumdefault.com
ServerAlias www.molybdenumdefault.com
ServerAlias webmail.molybdenumdefault.com
ServerAlias admin.molybdenumdefault.com
DocumentRoot /home/molybdenumdefault/public_html
ErrorLog /var/log/virtualmin/molybdenumdefault.com_error_log
CustomLog /var/log/virtualmin/molybdenumdefault.com_access_log combined
ScriptAlias /cgi-bin/ /home/molybdenumdefault/cgi-bin/
ScriptAlias /awstats /home/molybdenumdefault/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/molybdenumdefault/public_html>
Options -Indexes IncludesNOEXEC FollowSymLinks +ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/molybdenumdefault/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/molybdenumdefault/fcgi-bin/php5.fcgi .php5
<Directory /home/molybdenumdefault/cgi-bin>
allow from all
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.molybdenumdefault.com
RewriteRule ^(.*) https://molybdenum.lhsr.provide.net:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.molybdenumdefault.com
RewriteRule ^(.*) https://molybdenum.lhsr.provide.net:10000/ [R]
<Files awstats.pl>
AuthName "molybdenumdefault.com statistics"
AuthType Basic
AuthUserFile /home/molybdenumdefault/.awstats-htpasswd
require valid-user
RemoveHandler .php
RemoveHandler .php5
IPCCommTimeout 31

This was all generated by Virtualmin (except for the Rewrite tweaks). Changing the PHP script execution mode to Apache mod_php and back in Virtualmin correctly removes and re-adds the Handler directives but .php continues to not work correctly. No errors appear in the suexec, apache, or site logs when executing scripts.

We're kinda stumped at this point. Any ideas what could be causing these symptoms?

Closed (fixed)


Yeah, looking at your phpinfo() output, it looks like .php files are being processed by mod_php.

If you aren't using mod_php, you may want to disable it altogether. You can do that on the command line by running this command:

a2dismod php5

I recall an issue here with Apache's PHP config file, causing mod_php to override FCGId configuration for *.php files. Take a look at /etc/apache2/mods-available/php5.conf. Does it look like this for you?

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    <IfModule mod_userdir.c>
        <Directory /home/*/public_html>
            php_admin_value engine Off

If so, try commenting out (add # at the beginning) the two lines with the SetHandler directives. The regexps there look like they only apply to *.php, *.php3, *.phps and some others, but not to *.php5, that might be the reason why you experienced your issue.

If this was indeed the case, actually, the Vmin installer should have done this automatically meanwhile, since this issue has been reported a while back. Maybe the fix has not yet been included.

Disabling mod_php fixed the issue after removing the mod_php specific lines in a few user's apache config files. Those SetHandler directives are most likely the cause of the issue. Thank you andreychek and Locutus.

Glad to hear you got it working, thanks for the update!

Always appreciate you guys. Thanks again!

Hello, I'm having the same problem:

when php_mod is enabled, it seems to override fcgid in some cases.

The problem is that completely disabling php_mod prevents phpmyadmin to run.

So I need the following:

  • virtual servers created through Virtualmin (in /homes/*) should use only fcgid

  • other virtual servers (in /var/www/,like phpmyadmin) should use mod_php

How to achieve that?

Howdy -- don't forget that the support area here is for Virtualmin Pro customers :-) You're more than welcome to ask any questions you have in the forums though.

However, my recommendation would be to follow the advice of "Locutus" in comment #4 above, by commenting out the lines beginning with "SetHandler" in /etc/apache2/mods-available/php5.conf, then restart Apache. That should prevent mod_php from overriding fcgid/cgi.

Automatically closed -- issue fixed for 2 weeks with no activity.