Phpsuexec ?

Discussion in 'Installation/Configuration' started by linickx, Oct 14, 2006.

  1. linickx

    linickx Member

    Hi All,

    I'm new to this hosting thing, so sorry for the n00b question. I've got ISPConfig 2.2.7 on CentOs 4.4.

    I've read that PHPSUEXEC is a good thing to have, but can't find any CentOs packages (rpms) to install. Is this something I need to worry about ? Has all the "magic" ISPConfig done, already sorted this for me ?

    Thanks v.much.
    Nick.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The software is named SuPHP and not PHPSUEXEC. But I guess there is no SuPHP package for Centos available. You will have to compile and install it manually and then activate it in the ISPConfig configuration file: /home/admispconfig/ispconfig/lib/config.inc.php.

    Here is a guide for Debian, the installation steps for sentos will be similar, but the package installation command s will differ.

    http://www.howtoforge.com/apache2_suphp_php4_php5
     
  3. linickx

    linickx Member

    Hi Till,

    Aaaaaaahhh, I guess it helps to be searching for the right thing !

    Code:
    [root@server root]# yum search suphp
    Searching Packages:
    Setting up repositories
    Reading repository metadata in from local files
    
    mod_suphp.i386                           0.5.2-8.el4.kb         kbs-CentOS-Extra
    Matched from:
    mod_suphp
    suPHP is an apache module for executing PHP scripts with the permissions of
    their owners. It consists of an Apache module (mod_suphp) and a setuid root
    binary (suphp) that is called by the Apache module to change the uid of the
    process executing the PHP interpreter.
    http://www.suphp.org/
    You have new mail in /var/spool/mail/root
    [root@linickx ssh]#
    
    thanks v.much, I'll take a look your guide, and give it a go.

    rgds,
    Nick
     
  4. linickx

    linickx Member

    Solved

    As I've marked it as solved, it has been edited to make it more accurate. Edits are in bold, I hope it's not too confusing. (If you read the thread below, you'll see I didn't get it quite right 1st time) ;) - thanks to the people that helped me.


    It turns out this was really easy :)

    If you use CentOS..... (& followed this guide)

    Code:
    [b] cd /root 
    wget http://dag.wieers.com/packages/rpmforge-release/rpmforge-release-0.3.4-1.el4.rf.i386.rpm
    rpm -ivh rpmforge-release-0.3.4-1.el4.rf.i386.rpm [/b]
    yum [b] --disablerepo=kbs-CentOS-Extras[/b] install mod_suphp
    then edit /etc/httpd/conf.d/suphp.conf & comment out these lines like this...

    Code:
    [b]#[/b]AddHandler x-httpd-php .php
    [b]#[/b]AddHandler x-httpd-php .php .php4 .php3 .phtml
    [b]#[/b]suPHP_Engine on
    and tell ISPConfig about what you've done, edit /home/admispconfig/ispconfig/lib/config.inc.php find the line:

    Code:
    $go_info["server"]["apache2_php"] = 'both';
    
    and change to:

    Code:
    $go_info["server"]["apache2_php"] = 'suphp';
    
    to get ISPConfig to read the change, login to the web admin gui panel thing, find a website, and change the quota or something ( you can always change it back), and hit save

    finally you'll need to fix your php permissions....

    Code:
    updatedb
    locate .php | grep /var/www > /root/phpfiles.txt
    for i in `cat /root/phpfiles.txt ` ; do chmod -v 644 $i;done
    (you might also have to chmod 755 the "web" directory for each of your users )

    you may also want to fix proftp so that new files get the right permissions, I edited /etc/proftpd_ispconfig.conf and changed Umask to ....

    Code:
    Umask                   022
    you can then create a small php file to check it's working,

    Code:
    <? print "hello world<p>\n"; system("id"); ?>
    enjoy :D
     
    Last edited: Oct 16, 2006
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Thats not completely correct. You disabled the ability to configure php in ISPConfig.

    1) comment out the addhandler directives in the file /etc/httpd/conf.d/suphp.conf.

    2) Edit the file /home/admispconfig/ispconfig/lib/config.inc.php and enable suphp there.
     
  6. linickx

    linickx Member

    Doh ! n00b mistake !

    Done the "comment out the addhandler" thing & in /home/admispconfig/ispconfig/lib/config.inc.php I've set....

    Code:
    $go_info["server"]["apache2_php"] = 'suphp'; // 'filter' = set PHP filters, 'addtype' = Set PHP addtype or 'both' = Set Filter + Addtype, suphp = SuPHP wrapper enabled
    
    but now, my ID shows as apache :(

    have I missed something ?
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Have you created a administrator user for the website?
     
  8. linickx

    linickx Member

    Hi Till,

    Just checked, yes & it exists in /etc/passwd.... shell is /bin/false ... don't know if that makes a difference ?
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Just forgot one thing, please change a value in one of your websites, e.g. quota and hit safe to let ISPConfig rewrite you Vhost_ispconfig.conf file with the suphp settings.
     
  10. linickx

    linickx Member

    humm :confused: did that (changed the quota & hit save), and restarted apache (just in case)... still no joy, I've had a look at /etc/httpd/conf/vhosts/Vhosts_ispconfig.conf should "AddHandler x-httpd-php .php" be in there ? (it's not)
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    Please post the vhost configuration. Did you enable php in the site settings?
     
  12. linickx

    linickx Member

    yeah, here you go :) do you need any more ?

    Code:
    ######################################
    # Vhost: word.linickx.com:80
    ######################################
    #
    #
    <VirtualHost 192.168.116.129:80>
    ServerName word.linickx.com:80
    ServerAdmin [email protected]
    DocumentRoot /var/www/web4/web
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm defaul
    t.htm
    ErrorLog /var/www/web4/log/error.log
    AddType application/x-httpd-php .php .php3 .php4 .php5
    <Files *.php>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php3>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php4>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php5>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    php_admin_flag safe_mode Off
    Alias /error/ "/var/www/web4/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web4/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web4/user/$1/web/$3
    </VirtualHost>
    
    
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    It seems that the suphp settings have not been written to the config fle yet. Please check if there are any copies of the Vhost_ispconfig.conf file in the same directory with todays date appended in the name. If this is the case, make a backup of the file Vhost_ispconfig.conf and rename the latest file with date in name to Vhost_ispconfig.conf. then run httpd -t and post the error message here.
     
  14. linickx

    linickx Member

    ok, did that, here you go....

    Code:
    [root@linickx vhosts]# /usr/sbin/httpd -t
    Syntax error on line 30 of /etc/httpd/conf/vhosts/Vhosts_ispconfig.conf:
    Invalid command 'suPHP_UserGroup', perhaps mis-spelled or defined by a module not included in the server configuration
    [root@linickx vhosts]#
    
     
  15. falko

    falko Super Moderator Howtoforge Staff

    What's in that file, and what's in /etc/httpd/conf.d/suphp.conf now?
     
  16. linickx

    linickx Member

    Hello Falko,

    just...

    Code:
    LoadModule suphp_module modules/mod_suphp.so
    
    everything else is commented out... it's very odd, it's like the module isn't loading, but httpd.conf has load the vosts stuff last so it must be loaded ! :confused:
     
  17. helfrez

    helfrez New Member

    Solved!

    I would assume the same would apply to centos4. I was working on a rhel4 box that had the same issues. I used the mod_suphp from karan which produced the exact same scenario you have on centos4. On a whim a check dag for a module and it appeared that dag had the same version of the mod_suphp 0.6 that the tutorial uses, wheras the centos module is a 5.x version. I installed the mod_suphp found at dag.wieers.com for rl4 and restarted apache...NO ERRORS...the usergroup error went away and suphp appears to be workign and logging like a charm now.

    There must me a significant difference between the 0.5.x in karans repo and the 0.6.x in dags repo. Give it a shot!!

    http://dag.wieers.com/packages/mod_suphp/
     
  18. falko

    falko Super Moderator Howtoforge Staff

    What's in /etc/httpd/conf/vhosts/Vhosts_ispconfig.conf? What's the output of
    Code:
    httpd -V
    ?
     
  19. linickx

    linickx Member

    Hi All,

    Sorry, been a bit busy today...

    ok, tried Dag's suPHP - yay , that works - thanks helfrez :)

    (I think I'll edit my eariler post for other user's reference)

    but... now the php safe mode directives don't get loaded, I definitely ticked the box, and hit save, but look at the below vhost... oh well this is "livable" :)

    Code:
    [root@linickx vhosts]# /usr/sbin/httpd -V
    Server version: Apache/2.0.52
    Server built:   Aug 13 2006 03:29:43
    Server's Module Magic Number: 20020903:9
    Architecture:   32-bit
    Server compiled with....
     -D APACHE_MPM_DIR="server/mpm/prefork"
     -D APR_HAS_SENDFILE
     -D APR_HAS_MMAP
     -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
     -D APR_USE_SYSVSEM_SERIALIZE
     -D APR_USE_PTHREAD_SERIALIZE
     -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
     -D APR_HAS_OTHER_CHILD
     -D AP_HAVE_RELIABLE_PIPED_LOGS
     -D HTTPD_ROOT="/etc/httpd"
     -D SUEXEC_BIN="/usr/sbin/suexec"
     -D DEFAULT_PIDLOG="logs/httpd.pid"
     -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
     -D DEFAULT_LOCKFILE="logs/accept.lock"
     -D DEFAULT_ERRORLOG="logs/error_log"
     -D AP_TYPES_CONFIG_FILE="conf/mime.types"
     -D SERVER_CONFIG_FILE="conf/httpd.conf"
    [root@linickx vhosts]#
    
    
    /etc/httpd/conf/vhosts/Vhosts_ispconfig.conf

    Code:
    ######################################
    # Vhost: word.linickx.com:80
    ######################################
    #
    #
    <VirtualHost 192.168.116.129:80>
    ServerName word.linickx.com:80
    ServerAdmin [email protected]
    DocumentRoot /var/www/web4/web
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
    ErrorLog /var/www/web4/log/error.log
    AddType application/x-httpd-php .php .php3 .php4 .php5
    suPHP_Engine on
    suPHP_UserGroup web4_word web4
    AddHandler x-httpd-php .php .php3 .php4 .php5
    suPHP_AddHandler x-httpd-php
    Alias /error/ "/var/www/web4/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web4/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web4/user/$1/web/$3
    </VirtualHost>
    
    
     
  20. helfrez

    helfrez New Member

    Upgrade Blew Up

    I will chekc it out tonight, I'm trying to fix my sarge system now that was woarkign with suphp perfectly until I upgraded to 2.2.7 which seems to have blown up the suphp config and now nothing is working and all the suphp configs have been replaced by phpadmin values.
     

Share This Page