The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

phpsuexec patch for Apache

Discussion in 'EasyApache' started by bravado, Jan 17, 2006.

  1. bravado

    bravado Member

    Joined:
    Jan 16, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    My hosting provider uses cPanel and, more specifically, uses the phpsuexec patch to run PHP on Apache. I'm in the process of re-compiling Apache and PHP on my little production server for testing. However, the suexec php patches I've found don't appear to work right with Apache 1.3.34. So...what I was wondering is if it's possible someone could post or e-mail me a copy of the phpsuexec patch that cPanel uses for Apache 1.3.34.

    Thanks in advance! :)

    Jeff Whitfield
    jeffwhitfield@gmail.com
     
  2. kris1351

    kris1351 Well-Known Member

    Joined:
    Apr 18, 2003
    Messages:
    963
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Lewisville, Tx
    You can request a trial CPanel server from www.cpanel.net and that will allow you to setup the server exactly like your hosts.
     
  3. bravado

    bravado Member

    Joined:
    Jan 16, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Ok...I've installed Apache with the following patches from the cPanel trial I downloaded:

    apache_1.3.34-php-suexec-patch
    suexec+php-httpusergroupallow.patch

    The configure lines I used for Apache and PHP are as follows:

    PHP:

    ./configure --prefix=/usr --with-xml --enable-bcmath --enable-calendar --with-curl --with-dom --with-dom-xslt --with-dom-exslt --enable-exif --enable-ftp --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr --with-xpm-dir=/usr/X11R6 --with-gettext --with-kerberos --enable-mbstring --enable-mbstr-enc-trans --enable-mbregex --with-mcrypt --with-mhash --enable-magic-quotes --with-mysqli --with-mysql=/usr --enable-discard-path --with-pear --enable-xslt --with-xslt-sablot --enable-sockets --enable-track-vars --with-ttf --with-freetype-dir=/usr --enable-gd-native-ttf --enable-versioning --enable-wddx --with-xmlrpc --with-zip --with-zlib --with-iconv=/usr/local

    Apache:

    ./configure --with-layout=Apache --enable-module=expires --enable-shared=expires --enable-suexecphp --enable-module=rewrite --enable-shared=rewrite --enable-suexec --suexec-logfile=/usr/local/apache/logs/suexeclog --suexec-caller=nobody --suexec-uidmin=100 --suexec-gidmin=100 --suexec-docroot=/ --suexec-userdir=public_html

    I changed the httpd.conf file by adding ExecCGI to my root Apache htdocs directory and added the following line at the bottom:

    AddHandler application/x-httpd-php .php .php4 .php3

    Then I copied a simple phpinfo.php page to my htdocs folder, CHMOD'ed it to 755, and attempted to view it but got a 500 Internal Error instead with the following in my Apache error log:

    [Tue Jan 17 13:10:43 2006] [notice] Apache/1.3.34 (Unix) PHP-CGI/0.1b configured -- resuming normal operations
    [Tue Jan 17 13:10:43 2006] [notice] suEXEC mechanism enabled (wrapper: /usr/local/apache/bin/suexec)
    [Tue Jan 17 13:10:43 2006] [notice] Accept mutex: sysvsem (Default: sysvsem)
    [Tue Jan 17 13:11:15 2006] [error] [client 70.251.37.66] File does not exist: /usr/local/apache/htdocs/favicon.ico
    [Tue Jan 17 13:11:21 2006] [error] (8)Exec format error: exec of /usr/local/apache/htdocs/phpinfo.php failed
    [Tue Jan 17 13:11:21 2006] [error] [client 70.251.37.66] Premature end of script headers: /usr/local/apache/htdocs/phpinfo.php

    So...I guess I'm wondering where the problem lies. I'm lost! All I really want to do is get Apache and PHP configured so that it mimics a similar configuration to what cPanel uses. My hosting provider uses the phpsuexec methods so I really need to get this working...else I won't have a properly configured test server. Ugg! What a headache! LOL!

    Thanks in advance! :)

    Jeff
     
  4. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Set the permissions on phpinfo.php to 644.
     
  5. bravado

    bravado Member

    Joined:
    Jan 16, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Nope! That didn't do it! Hmm....
     
  6. bravado

    bravado Member

    Joined:
    Jan 16, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Well...Apache is set to run with the user/group of 'nobody'. I tried setting the ownership of the phpinfo.php file to something like wwwrun:users but still get the error. I know that you can't have the ownership set to root so no problem there. Hmm...I seem to be missing something somewhere in terms of permission settings.
     
  7. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Might have lead you astray as I have had apache safe_mode on the brain lately.

    Max perms would be 755 but normally 644 should work. Also files and directories should be owned user/group.
     
  8. bravado

    bravado Member

    Joined:
    Jan 16, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    According to what I've read, since I compiled Apache to use a user/group id of 100 then that would mean that so long as the file being executed has a user/group id that is 100 or below then Apache will allow it to be executed. Apache itself is set to run as user/group 'nobody'...but I'm not sure how much bearing this has on suexec settings. So long as I can get PHP to work in my main htdoc directory and any subdirectory below it, I'll be fine. But for now, this is getting tricky!

    One thing I notice, and I can't believe I didn't think of this, is that the PHP executable seemed to be one I used previously. I did the following on the command line:

    php -v

    and ended up with some info that told me I was running version 4.3.10 instead of 4.4.1. So...I removed every instance of PHP and reinstalled it. First thing after I did that I repeated the same command. This time, I got an error telling me that /usr/local/bin/php didn't exist. Strange. So I copied the binary from /usr/bin to /usr/local/bin and all appears fine from the command line so PHP is the right version now...but still a no-go! ARGG! Man...this phpsuexec stuff is frustrating! LOL!
     
  9. PDM

    PDM Active Member

    Joined:
    Jan 7, 2004
    Messages:
    43
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Angel Fire, NM
    Make sure you don't have a .htaccess in that folder with php commands in it.
     
  10. bravado

    bravado Member

    Joined:
    Jan 16, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    One step ahead of ya! We're talkin' a plain-Jane install with nothing but the default index.html in the htdocs folder...nothing to get in the way.
     
  11. bravado

    bravado Member

    Joined:
    Jan 16, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    A little update on my progress. I decided to rebuild Apache with the following config line:

    ./configure --with-layout=Apache --enable-module=expires --enable-shared=expires --enable-suexecphp --enable-module=rewrite --enable-shared=rewrite --enable-suexec --suexec-logfile=/usr/local/apache/logs/suexeclog --suexec-caller=apache --suexec-uidmin=50 --suexec-gidmin=50 --datadir=/home/apache --suexec-userdir=public_html

    Before that though I created a new user/group called 'apache' with a user/group id of 50. I figured that part of my problem might be related to user rights. Before configuring and installing Apache, I applied the same patches as before (apache_1.3.34-php-suexec-patch and suexec+php-httpusergroupallow.patch). After the install, I updated the httpd.conf file to use the new 'apache' user when running the daemon. I then chown'ed everything in the /home/apache directory to apache:apache so the user that owns the suexec call is the same. Placed a phpinfo.php file in the htdocs, changed the ownership and permissions, and attempted to view the file....same error! (8)Exec format error.

    Sigh! This PHPSuExec stuff is for the birds! LOL! I'm missing something somewhere!
     
Loading...

Share This Page