2013-07-01 52 views
1

我需要在虛擬主機上禁用mod_php並讓它爲其他虛擬主機工作,爲了激活suphp,我需要禁用它。在虛擬主機中禁用MOD_PHP並激活suphp

這裏是虛擬主機配置:



    Options +Indexes 
    ServerName www.native.org 
    ServerAlias native.org 
    DocumentRoot /home/user/www/native/current 
    ServerAdmin [email protected] 
    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> 

NB:mod_php,並且默認情況下,所有激活的虛擬主機

+0

最有可能Serverfault – Dave

回答

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 /共享/ phpMyAdmin的phpMyAdmin安裝,它會在mod_php的工作,這是偉大的。)

最後,來看看我的VirtualHosts配置之一:

<VirtualHost 1.2.3.4:80> 
    ServerName site.com 
    ServerAlias www.site.com 
    ServerAdmin [email protected] 
    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> 

最後請注意:

如果你的phpMyAdmin的位於在/ usr /共享/ phpMyAdmin的是不工作,你的httpd.conf結束或在您的主虛擬主機添加以下行:

<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 [email protected] 
    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> 
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> 
+0

的工作問題,PHP是沒有更多的解釋,但我不能運行suphp –