1

We're running a webserver using Debian 6.0.3 with Apache 2, we recently upgraded from Debian 5 to 6. Since then php scripts in the user directories (using mod_userdir) have stopped working, they are downloaded instead of being executed.

There is also a website using php outside of the user directories, and that one continues to work fine, so PHP seems to generally work on the server. I tested it with several PHP files, among the a simple phpinfo file that works fine on the main site, but is just downloaded when copying it to one of the user directories.

The php files and the directory containing them are executable for everyone. The option in the Apache php5.conf that by default disables PHP in the user directories, is commented out, so the php5.ini looks like this:

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    # 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>
</IfModule>

We restarted Apache after changing this. I'm running out of ideas now what the problem could be, and I don't know how I could really determine which problem is preventing those php files from being executed. Any ideas on how I can solve this?

Update:

Strangely, PHP seems to work fine in subfolders of user directories, so if I copy a PHP file from /home/user/public_html/ to /home/user/public_html/test/ it suddenly works.

2 Answers2

1

For starters, try

egrep -ir "(php_admin_value|mod_userdir|public_html)" /etc/apache2

and see all the possible places where PHP for user directories might get disabled. Change where needed. Restart Apache, enjoy.

Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
  • 1
    Thanks for the idea, but unfortunately that command only finds something in the php5 and the userdir config files I both checked already. The only instance of PHP disabling I found was in the php5.conf, and that one I already disabled. –  Nov 15 '11 at 11:53
  • @user51326, So how did you solve it? [Don't just run away.](https://www.quora.com/What-is-a-coders-worst-nightmare/answer/Jorge-Irun) – Pacerier Apr 03 '15 at 18:03
0

I experienced the same problem and resolved it by installing

apt-get install libapache2-mod-php5
Falcon Momot
  • 24,975
  • 13
  • 61
  • 92