HOWTO : SuPHP

nebukazar

Verified User
Joined
Sep 28, 2003
Messages
130
Here are the steps I did to install suPHP under Redhat 9.0 :

1- Get suPHP :
wget http://www.suphp.org/download/suphp-0.5.tar.gz

2- Unpack the archive and enter into the created directory :
tar -zxvf suphp-0.5.tar.gz ; cd suphp-0.5/

3- Copy your current php bin :
cp -p /usr/local/bin/php /usr/local/bin/php.CLI

- Download, extract php CGI :
Make sure you are running Redhat9.0 and you are using PHP 4.3.4 :
wget http://katou.nebukazar.net/CGI-php-v4.3.4-rh9.tar.gz
tar -zxvf CGI-php-v4.3.4-rh9.tar.gz ; cp -fp CGI-php-v4.3.4-rh9/php /usr/local/bin/php.CGI

If you are not using Redhat 9 or you're not using the same PHP version, you can download your PHP version, configure then make. The CGI php version is located under : [PHP-Directory]/sapi/cgi/php

4- Configure suPHP to your system :
./configure --with-apache-user=apache --with-php=/usr/local/bin/php.CGI --disable-checkpath --disable-checkuid --disable-checkgid --with-min-uid=0 --with-min-gid=0

5- Make :
make

6- Before doing make install, please keep a backup of your httpd.conf :
cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak

7- Make install suPHP :
make install

8- Edit your httpd.conf
- vi or pico /etc/httpd/conf/httpd.conf

locate :
<IfModule mod_php4.c>
AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>

and replace with :
<IfModule mod_php4.c>
suPHP_Engine on
AddHandler x-httpd-php .php
AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps

9- Change 1 setting in your php.ini (!! Make sure you are editing the right php.ini file !!):
vi or pico /usr/local/lib/php.ini

find :

;cgi.force_redirect =

and change it to :

cgi.force_redirect = 0

10- Restart httpd :
service httpd restart

suPHP log is installed under /etc/httpd/logs/suphp_log

If you need more help PM me or contact me at [email protected]
 
Last edited:
Quick question,

This is compiling php barebone right?. So it doesn't include cURL etc etc.

How do we compile it with say...

imap, curl, mcrypt, gd, mhash, freetype?
 
Hi,

suPHP is only a wrapper. It will take the actual php binary and will execute the binary as the user.

So, you will need to compile the cgi php binary with all the options you want (cURL, mcrypt, etc.)
 
Is there any known problems with changing layout while running suPHP? As we tried now we get this error:

Status: 0 Content-type: text/html Security Alert! The PHP CGI cannot be accessed directly.
This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.
For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit the manual page.

I think this flag (force-cgi-redirect) was set while installing suPHP. Is it neccassary? How do we solve this problem?
 
hi,

it is necessary otherwise you won't be able to use php-cgi correctly.

regards,
 
how did you get webmail/squirrelmail/phpmyadmin working?

everything works here except those 3
 
hi,

make sure both php are installed on your server. CGI and CLI

Do you get any errors ?
Did you take a look @ your logs ?
 
yes, got both installed

suphp.log:

[Thu Aug 19 00:13:14 2004] [error] Script /var/www/html/webmail//index.php is not in the DOCUMENT_ROOT (/home/user/domains/domain.com/public_html)

i know it goes though suphp, but just want to know how you did it?

and another thing, i actualy have the idea that apache is crashing on something

[Wed Aug 18 21:23:51 2004] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Aug 18 21:23:51 2004] [notice] Accept mutex: sysvsem (Default: sysvsem)
[Wed Aug 18 21:25:03 2004] [error] [client 82.192.xx.xx] request failed: URI too long
[Thu Aug 19 00:11:00 2004] [notice] caught SIGTERM, shutting down
[Thu Aug 19 00:11:01 2004] [notice] Apache/1.3.31 (Unix) mod_ssl/2.8.19 OpenSSL/0.9.7a PHP/4.3.8 mod_perl/1.27 FrontPage/5.0.2.2510 configured -- resuming normal operations
 
Last edited:
SuPHP on FreeBSD 4.10

I got SuPHP working on FreeBSD 4.10, the only thing different I had to do was copy the php-4.3.9.tar.gz to another directory and run my normal configure, but without the:
--with-apxs \
line. Then I ran make, but NOT make install
Then I copied sapi/cgi/php to /usr/local/bin/php.CGI and made the other changes. That was it.
 
php.CGI

Hi I couldn't find the php.CGI, so i rebuild php with options --enable-cgi

I've runned configure of suphp like this: ./configure --with-apache-user=apache --disable-checkpath --disable-checkuid --disable-checkgid --with-min-uid=0 --with-min-gid=0

After restarting I get internal servererrors when requesting php pages.

In the logging it says:

[Mon Feb 14 09:16:24 2005] [error] System error: execl() failed (No such file or directory)
[Mon Feb 14 09:16:24 2005] [info] Executing /home/wil/domains/public_html/forum/index.php as user wil (1017),
group wil (1017)
[Mon Feb 14 09:16:24 2005] [error] System error: execl() failed (No such file or directory)

Can anyone help?
 
Last edited:
php.CGI

I tried to do a custom php build, in order to include the cgi.

I went to directory:
/usr/local/directadmin/customapache/php-4.3.10
Which is the version I use, and tried using the configure options (as displayed by phpinfo), and added --enable-cgi

After running ./configure and make it does not create any php binary in sapi/cgi

Do I need to run a build with --disable-cli? Because, then I would have to remove pear as well, and I don't know if that is good or bad.

Cheers
 
I got to creating a CGI edition, by adding --enable-cgi, and REMOVING --with-apxs from the configure line.
 
Dito here. Just got a problem with --with-php=/usr/local/bin/php.cgi

It doesn't use that var :s, it keeps looking at /usr/bin/php which is a link to /usr/local/bin/php, so I changed that link to /usr/local/bin/php.cgi

And now it Rocks, at last. I'm currently testing and, when everything goes well, I will change domain by domain to suphp.

I will default enable it for new clients :D.
 
In case someone doesn't know for sure: suPHP works perfectly fine with PHP5 (I wasn't sure because I couldn't get it compiled with php5 properly before).

It's great to watch 'top' now ;).

Jochem
 
I don't understand this :

- Download, extract php CGI :
Make sure you are running Redhat9.0 and you are using PHP 4.3.4 :
wget http://katou.nebukazar.net/CGI-php-v4.3.4-rh9.tar.gz
tar -zxvf CGI-php-v4.3.4-rh9.tar.gz ; cp -fp CGI-php-v4.3.4-rh9/php /usr/local/bin/php.CGI

If you are not using Redhat 9 or you're not using the same PHP version, you can download your PHP version, configure then make. The CGI php version is located under : [PHP-Directory]/sapi/cgi/php

In fact i have fedora, what do i have to do ? Because i can't download this file ... Where can i find one for my system and php 4.3.11 ?

Tanks :)
 
Back
Top