我需要在vhost上停用mod_php并让它为其他vhost工作,我需要禁用它才能激活suphp。
这是vhost配置:
Options +Indexes
ServerName www.native.org
ServerAlias native.org
DocumentRoot /home/user/www/native/current
ServerAdmin info@native.org
UseCanonicalName Off
CustomLog /var/log/apache2/native_access.log combined
ErrorLog /var/log/apache2/native_error.log
<Directory /home/user/www/native/current>
RemoveHandler .php
AllowOverride All
Options FollowSymLinks
Order allow,deny
allow from all
</Directory>
suPHP_Engine on
SuexecUserGroup user native
<IfModule mod_suphp.c>
suPHP_UserGroup user native
AddHandler x-httpd-php .php .php3 .php4 .php5
suPHP_AddHandler x-httpd-php
</IfModule>
注意:默认情况下,所有vhosts都会激活mod_php
答案 0 :(得分:2)
你应该能够做到
<Directory /home/user/www/native/current>
RemoveHandler .php .phtml .php3 .php5
RemoveType .php .phtml .php3 .php5
php_flag engine off
AllowOverride All
Options FollowSymLinks
Order allow,deny
allow from all
</Directory>
答案 1 :(得分:2)
您不必删除处理程序,类型或关闭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>