Virtualmin on Debian 7 : PHP code not interpreted in mod_php mode

11 posts / 0 new
Last post
#1 Sun, 06/09/2013 - 14:47
Nico94

Virtualmin on Debian 7 : PHP code not interpreted in mod_php mode

Hello everybody,

I installed Virtualmin for the first time on Debian 7 like I already did a zillion times before on Debian 6. As usual, I ran this on a freshly installed dedicated server:

apt-get update
apt-get upgrade
wget http://software.virtualmin.com/gpl/scripts/install.sh
chmod +x install.sh
./install.sh

... ans answered the usual questions of the post-install process.

Everything went fine (thanks a lot for this great panel, you guys rock :-) ... but still, I'm runing into a strange problem: whenever I try to switch a website's PHP execution mode to "Apache mod_php", the code seems to be not interpreted and shows up in the browser.

Same symptom if I try to put some PHP scripts in /var/www, just have a look here : http://176.31.127.227/phpinfo.php

Am I the only one concerned ? Any clue ?

Sun, 06/09/2013 - 22:18
andreychek

Howdy,

Hmm, that's an unusual issue!

If you go into System Settings -> Re-Check Config, does it detect any errors?

-Eric

Tue, 06/11/2013 - 09:38
Nico94

Hi Eric,

Thank you for the quick answer. Virtualmin seems to be happy :

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 1.94 GB of memory, which is at or above the Virtualmin recommended minimum of 256 MB.
BIND DNS server is installed, and the system is configured to use it.
Mail server Postfix is installed and configured.
Postfix is configured to support per-domain outgoing IP addresses.
Apache is installed.
The following PHP versions are available : 5.4.4 (/usr/bin/php5-cgi)
Webalizer is installed.
Apache is configured to host SSL websites.
MySQL is installed and running.
ProFTPd is installed.
Logrotate is installed.
SpamAssassin and Procmail are installed and configured for use.
ClamAV is installed and assumed to be running.
Plugin AWstats reporting is installed OK.
Plugin DAV Login is installed OK.
Plugin Mailman is installed OK.
Plugin Protected web directories is installed OK.
Using network interface eth0 for virtual IPs.
IPv6 addresses are available, using interface eth0.
Default IP address for virtual servers is 176.31.127.227.
Default IP address is set to 176.31.127.227, which matches the detected external address.
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.
.. your system is ready for use by Virtualmin.

I agree: this is quite odd. I wonder if I don't have some kernel issue here, this is my next testing step. Meanwhile, any idea is very welcome :)

Thu, 06/13/2013 - 08:02
miner

Hi,

Please check /etc/apache2/mods-enabled/php5.conf

to see if/that the two SetHandler lines are commented out.

Mon, 06/17/2013 - 15:40
Nico94

Hey, that was it! Thank you very much indeed :)

Fri, 06/21/2013 - 05:11
Nico94

Mmm... It seems to be a little more tricky: if I comment the 2 "SetHandler" lines, I get the exact opposite situation :

  • PHP scripts are interpreted in /var/www AND for websites runing "Apache mod_php".
  • Unfortunatly, websites runing FCGId show the code in the browser

Here is my /etc/apache2/mods-enabled/php5.conf :

<FilesMatch ".+\.ph(p[345]?|t|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Order Deny,Allow
    Deny from all
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
    Order Deny,Allow
    Deny from all
</FilesMatch>

# Running PHP scripts in user directories is disabled by default
#
# 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
    </Directory>
</IfModule>

Any further idea ?

Mon, 06/24/2013 - 12:27
Goeny

I had the same issue. In my case it was a mime-type issue.

In the global apache configuration go to mime types. Check if application/x-httpd-php is in the list. If not... "Add new mimetype"

MIME type = application/x-httpd-php extensions = php

That worked for me.

Sun, 12/07/2014 - 11:21 (Reply to #7)
lupus

It was a mime type issue here as well (Ubuntu 14.04).

Not sure why but the line was commented out in /etc/mime.types .

Thanks alot!

Thu, 06/27/2013 - 11:35
Nico94

Bingo, that was it: the line...

application/x-httpd-php                        phtml pht php

... was commented in /etc/mime.types. Thanks a lot Goeny.

@ the dev team : wouldn't it be a good idea to add a few lines to the install script in order to check this ?

Sun, 05/25/2014 - 09:24
jonnybradley

Fixed it for me too, thanks!

Wed, 07/30/2014 - 04:40
taveren

Thank you!

Had the same issue on fresh Ubuntu 14.04 installation.

Adding mime type helped!

Topic locked