您不必删除处理程序、类型或关闭 PHP 的引擎.
在您<VirtualHost ...>
添加以下行:
<FilesMatch \.php$>
SetHandler None
</FilesMatch>
通过这种方式,您将删除/etc/httpd/conf.d/php.conf(或 php5.conf 或其他)添加的处理程序,其中显示:
#
# Cause the PHP interpreter to handle files with a .php extension.
#
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
编辑:最好也根据suphp.conf文件禁用 PHP 引擎:
# Disable php when suphp is used, to avoid having both.
<IfModule mod_php5.c>
php_admin_flag engine off
</IfModule>
您的站点现在将在 suPHP 下运行。(另外,如果你在 /usr/share/phpMyAdmin 中安装了 phpMyAdmin,它可以在 mod_php 下工作,这很好。)
最后,看看我的一个 VirtualHosts 配置:
<VirtualHost 1.2.3.4:80>
ServerName site.com
ServerAlias www.site.com
ServerAdmin admin@site.com
DocumentRoot /home/site/public_html
Options -Indexes
suPHP_Engine on
suPHP_UserGroup site site
suPHP_ConfigPath "/home/site/public_html"
suPHP_AddHandler x-httpd-php
AddHandler x-httpd-php .php .php3 .php4 .php5
# Remove the handler added by php.conf
<FilesMatch \.php$>
SetHandler None
</FilesMatch>
# Disable php when suphp is used, to avoid having both.
<IfModule mod_php5.c>
php_admin_flag engine off
</IfModule>
ErrorLog "|cronolog /home/site/.logs/error_%Y_%m.log"
CustomLog "|cronolog /home/site/.logs/access_%Y_%m.log" combined
</VirtualHost>
最后注:
如果您位于/usr/share/phpMyAdmin的 phpMyAdmin 不起作用,请在httpd.conf末尾或您的主 VirtualHost 中添加以下行:
<Directory /usr/share/phpMyAdmin>
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
<IfModule mod_php5.c>
php_admin_flag engine on
</IfModule>
</Directory>
例如:
<VirtualHost 1.2.3.4:80>
ServerAdmin admin@master-site.com
DocumentRoot /var/www/html
Options -Indexes
<Directory /usr/share/phpMyAdmin>
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
<IfModule mod_php5.c>
php_admin_flag engine on
</IfModule>
</Directory>
ErrorLog "|cronolog /var/www/.logs/error_%Y_%m.log"
CustomLog "|cronolog /var/www/.logs/access_%Y_%m.log" combined
</VirtualHost>