Вопрос

I need to desactivate mod_php on a vhost and let it working for other vhosts, I need to disable it in order to activate suphp.

here is the vhost config :



    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>

NB: mod_php is activated by default for all vhosts

Это было полезно?

Решение

You don't have to remove handlers, types or to turn PHP's engine off.

In your <VirtualHost ...> add the following lines:

<FilesMatch \.php$>
    SetHandler None
</FilesMatch>

In this way, you will remove the handler added by /etc/httpd/conf.d/php.conf (or php5.conf, or whatever) which says:

#
# Cause the PHP interpreter to handle files with a .php extension.
#
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

Edit: It's better also to disable PHP's engine according to suphp.conf file:

# Disable php when suphp is used, to avoid having both.
<IfModule mod_php5.c>
    php_admin_flag engine off
</IfModule>

Your site will run under suPHP now. (Also, if you have installed phpMyAdmin in /usr/share/phpMyAdmin, it will work under mod_php, which is great.)

At the end, take a look of one of my VirtualHosts configuration:

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

Final Note:

If your phpMyAdmin located in /usr/share/phpMyAdmin is not working, add the following lines at the end of your httpd.conf or in your master VirtualHost:

<Directory /usr/share/phpMyAdmin>
  <FilesMatch \.php$>
    SetHandler application/x-httpd-php
  </FilesMatch>

  <IfModule mod_php5.c>
    php_admin_flag engine on
  </IfModule>
</Directory>

For example:

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

Другие советы

You should be able to do

<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>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top