我有一个Debian Lenny Web服务器.它使用libapache2-mod-suPHP运行apache2.不幸的是,suPHP无法使用PHPmyadmin,因为PHPmyadmin安装在/usr/share / PHPmyadmin并由root拥有,而suPHP在这个目录中禁用了它的引擎:
$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>
是否有可能在使用suPHP时启用系统PHPmyadmin(可能通过标准libapache2-mod-PHP5)?怎么样?
解决方法
在/etc/apache2/mods-available/suPHP.conf中有以下两行:
AddType application/x-httpd-PHP .PHP .PHP3 .PHP4 .PHP5 .phtml suPHP_AddHandler application/x-httpd-PHP
应改为:
AddType application/x-httpd-suPHP .PHP .PHP3 .PHP4 .PHP5 .phtml suPHP_AddHandler application/x-httpd-suPHP
application/x-httpd-PHP=PHP:/usr/bin/php-cgi
应改为:
application/x-httpd-suPHP=PHP:/usr/bin/php-cgi
然后,应该改变/etc/apache2/mods-available/PHP5.conf的内容:
<IfModule mod_PHP5.c> AddType application/x-httpd-PHP .PHP .phtml .PHP3 AddType application/x-httpd-PHP-source .PHPs </IfModule>
至:
<Directory /usr/share> <IfModule mod_PHP5.c> AddType application/x-httpd-PHP .PHP .phtml .PHP3 AddType application/x-httpd-PHP-source .PHPs </IfModule> </Directory>
这样,所有PHP脚本都被分配了x-httpd-suPHP类型,由suPHP处理.由于对/usr/share中的文件禁用了suPHP,因此在PHP5.conf中,PHP脚本获取x-httpd-PHP的类型并由mod_PHP5处理.这样,除了/usr/share中系统安装的脚本外,您保留所有其他脚本的suPHP.