Universal httpd.template (mod_php+mod_ruid2 and php-cgi+suPHP)

JohnyByk

Verified User
Joined
Mar 7, 2012
Messages
251
Hi.

I have PHP 5.2 (module) and 5.3 (php-cgi) on server.
PHP module uses mod_ruid2, php-cgi uses suPHP. PHP 5.3 dosen't work (internal error), when mod_ruid is active in user httpd.conf. This is not the problem - i can edit users files, but files are rewrites with DA (from template). Is way for universal tempalte (works with php-cg+suPHP and mod_php+mod_ruid2).

My template:
Code:
<VirtualHost |IP|:|PORT_80| |MULTI_IP|>
|CUSTOM|
|?CGI=ScriptAlias /cgi-bin/ `DOCROOT`/cgi-bin/|
        ServerName www.|DOMAIN|
        ServerAlias www.|DOMAIN| |DOMAIN| |SERVER_ALIASES|
        ServerAdmin |ADMIN|
        DocumentRoot |DOCROOT|
        |CGI|

        |USECANONICALNAME|
        <IfModule !mod_suphp.c>
                RMode config
                RUidGid |USER| |GROUP|
                RGroups apache access
        </IfModule>

        CustomLog /var/log/httpd/domains/|DOMAIN|.bytes bytes
        CustomLog /var/log/httpd/domains/|DOMAIN|.log combined
        ErrorLog /var/log/httpd/domains/|DOMAIN|.error.log

        |*if SUSPENDED_REASON|
        <IfModule mod_env.c>
                SetEnv reason |SUSPENDED_REASON|
        </IfModule>
        |*endif|

        <Directory |DOCROOT|>
                Options +Includes -Indexes

|*if HAVE_SAFE_MODE="1"|
                php_admin_flag safe_mode |SAFE_MODE|
|*endif|
|*if CLI="1"|
                php_admin_flag engine |PHP|
                php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f |USER|@|DOMAIN|'
|*endif|
|*if OPEN_BASEDIR="ON"|
                php_admin_value open_basedir |OPEN_BASEDIR_PATH|
|*endif|
|*if SUPHP="1"|
                suPHP_Engine |PHP|
                suPHP_UserGroup |USER| |GROUP|
|*endif|
        </Directory>
|HANDLERS|
|MIMETYPES|

</VirtualHost>
 
Log:
Code:
[Thu Dec 06 15:30:03 2012] [error] [client 89.71.69.253] SecurityException in Application.cpp:175: Calling user is not webserver user!
[Thu Dec 06 15:30:03 2012] [error] [client 89.71.69.253] Premature end of script headers: index.php

I know what is the cause of that.
This:
Code:
suPHP_Engine ON
suPHP_UserGroup essey essey

can't work with this:
Code:
RMode config
RUidGid essey essey
RGroups apache access

mod_php work's with suPHP settings (are likely to be ignored) but pgp-cgi don't ignore mod_ruid settings (RMode, RUidGid, RGroups). This is the reason of internal server error.

Best solution for me is change httpd.conf user template which will be compatible with both options. I don't know how to do that (maybe with use IfModule?)
 
The default is mod_php (PHP 5.2). Users can switch to PHP 5.3 (. Htacces). If mod_ruid2 is active it does not work PHP 5.3. The problem is suPHP settings in the configuration file. I would like to have a template that works with mod_ruid and suPHP. It is even possible? Is waiting for my users manually change settings using PHP 5.2 (adding mod_ruid2)?
 
Just rebuild suPHP and it should solve your problems:
Code:
cd /usr/local/directadmin/custombuild
./build update
./build suphp
 
suPHP works fine but only if mod_ruid2 is not active in the configuration file (these modules do not work together). This is not a problem. After commenting RMode, RUidGid, RGroups suPHP and php-cgi all it's OK. The problem is that I have to comment out the entries in the users configration files (users who use PHP 5.3). Configuration must select the module depending on the version of PHP (or cgi mod) to avoid conflicts. If this can not be done with this template may be another way to solve the problem?
 
Last edited:
suPHP works fine but only if mod_ruid2 is not active in the configuration file (these modules do not work together). This is not a problem. After commenting RMode, RUidGid, RGroups suPHP and php-cgi all it's OK. The problem is that I have to comment out the entries in the users configration files (users who use PHP 5.3). Configuration must select the module depending on the version of PHP (or cgi mod) to avoid conflicts. If this can not be done with this template may be another way to solve the problem?

They do work together, because suPHP has a patch applied a default with any version of CB. That's why you need to reinstall suPHP (to make it compatible).
 
You have right.
You're right. Thank you for your help.

Now all works fine.
 
Back
Top