Linux – Running phptheadmin and suphp

apache-2.2linuxphp5suphp

I have a Debian Lenny web server. It is running apache2 with libapache2-mod-suphp. Unfortunately, suphp makes impossible to use phpmyadmin, as phpmyadmin is installed in /usr/share/phpmyadmin and owned by root, and suphp disables it's engine in this direcory:

$ cat /etc/apache2/mods-enabled/suphp.conf 
<IfModule mod_suphp.c>
    AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
    suPHP_AddHandler application/x-httpd-php
    <Directory />
        suPHP_Engine on
    </Directory>

    # By default, disable suPHP for debian packaged web applications as files
    # are owned by root and cannot be executed by suPHP because of min_uid.
    <Directory /usr/share>
        suPHP_Engine off
    </Directory>
</IfModule>

Is there a possibility to enable system phpmyadmin (may be through standard libapache2-mod-php5) while using suphp? How?

Best Answer

In /etc/apache2/mods-available/suphp.conf following two lines:

AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
suPHP_AddHandler application/x-httpd-php

should be changed to:

AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml
suPHP_AddHandler application/x-httpd-suphp

Then, in /etc/suphp/suphp.conf line

application/x-httpd-php=php:/usr/bin/php-cgi

should be changed to:

application/x-httpd-suphp=php:/usr/bin/php-cgi

Then, contents of /etc/apache2/mods-available/php5.conf should be changed from:

<IfModule mod_php5.c>
  AddType application/x-httpd-php .php .phtml .php3
  AddType application/x-httpd-php-source .phps
</IfModule>

to:

<Directory /usr/share>
    <IfModule mod_php5.c>
      AddType application/x-httpd-php .php .phtml .php3
      AddType application/x-httpd-php-source .phps
    </IfModule>
</Directory>

This way, all php scripts get assigned x-httpd-suphp type which is handled by suphp. As suphp is disabled for files in /usr/share, in php5.conf for this directory php scripts get type of x-httpd-php and are handled by mod_php5. This way, you retain suphp for all other scripts except for system-installed ones in /usr/share.