1

我需要停用 vhost 上的 mod_php 并让它为其他 vhost 工作,我需要禁用它才能激活 suphp。

这是虚拟主机配置:



    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>

注意:mod_php 默认为所有虚拟主机激活

4

2 回答 2

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>
于 2013-07-01T16:18:58.380 回答
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>
于 2014-08-26T12:25:21.457 回答