簡體   English   中英

在vhosts中禁用MOD_PHP並激活suphp

[英]Disable MOD_PHP in vhosts and activate suphp

我需要在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>

注意:默認情況下,所有vhost都會激活mod_php

你應該能做到的

<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>

您不必刪除處理程序,類型 或者關掉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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM