php4 and php5 with suphp

Discussion in 'Tips/Tricks/Mods' started by smartcall, Dec 3, 2006.

  1. smartcall

    smartcall ISPConfig Developer ISPConfig Developer

    Hello to all!

    I installed the panel and both php4 and php5 as cgi. I also installed suphp and made it work. By default my handler adds php4 to the configuration of the hosts.
    I would like to give the users the ability to switch between php4 and php5. But seems that suPHP_AddHandler can't be added to .htaccess and there is no way to override the the default:

    AddType application/x-httpd-php .php .php3 .php4 .php5
    AddHandler x-httpd-php .php .php3 .php4 .php5
    suPHP_AddHandler x-httpd-php


    AddType application/x-httpd-php5 .php .php3 .php4 .php5
    AddHandler x-httpd-php5 .php .php3 .php4 .php5
    suPHP_AddHandler x-httpd-php5

    from .htaccess

    So my question is - can I add a checkbox in any of the forms and then modify the vhosts template to change 'x-httpd-php' to 'x-httpd-php5' and vice versa. And if I do so which files and how to retain such functionality after an upgrade.

    And another question - what security level adds suphp? Because I still can open files from other directories with php scripts that I run in my webroot.


  2. smartcall

    smartcall ISPConfig Developer ISPConfig Developer

    suphp with both php5 and php4

    Looks like nobody is interested in how to do this.
    But I need it and found out the solution. It's not perfect, because an upgrade of the panel would destroy the additions to the code.

    This is how I did it:
    1. I have both php4 and php5 compiled with fastcgi option and all other options that I need.
    2. I have the suPHP installed and WORKING as per the Falko's tutorial.
    3. I edited the form 'ISP Web' and added a checkbox called php_5 to the Options tab.
    4. I edited the file /root/ispconfig/scripts/lib/config.lib.php
    and changed the original code to

    if($go_info["server"]["apache2_php"] == 'suphp'){
    $php .= "suPHP_Engine on\n";
    $php .= "suPHP_UserGroup ".$webadmin." web".$web["doc_id"]."\n";
    $php .= "AddHandler x-httpd-php5 .php .php3 .php4 .php5\n";
    $php .= "suPHP_AddHandler x-httpd-php5\n";
    else {
    $php .= "suPHP_Engine on\n";
    $php .= "suPHP_UserGroup ".$webadmin." web".$web["doc_id"]."\n";
    $php .= "AddHandler x-httpd-php .php .php3 .php4 .php5\n";
    $php .= "suPHP_AddHandler x-httpd-php\n";

    And it works.

    I would like to have some feedback from any of the developers. But not necessarily, as I notice that this topic is not very interesting to anyone in this forum.


  3. xrat

    xrat Member

    NACK, I am. And by definition, I != nobody ;)
    I am looking for something similar. I want to make suPHP optional, so I can switch it on and off on a per site basis. Your solution points me to the right place but where is the form 'ISP Web'? I can't find it (by means of grep and such).
  4. vogelor

    vogelor ISPConfig Developer ISPConfig Developer

    I am just 1 more (means at least 2 ;-)
    The form ist NOT a file. Just log in and goto:
    Administration/Form Designer/Edit form.
  5. xrat

    xrat Member

    Way cool! Thanks a lot. I have definitely been looking at the wrong place for something that wouldn't have been there anyway :eek:

    So, now I added a checkbox to the form ISP Web. In /root/ispconfig/scripts/lib/config.lib.php after
    if($go_info["server"]["apache2_php"] == 'suphp'){
    I inserted a little quick and dirty
    if($web["mycheckbox"]){...}else{... original code ...}
    to make config.lib.php disable "suPHP_Engine".

    Drop me a line if someone wants the complete patch.
    Thanks to all, and especially to the developers for ISPconfig.
  6. smartcall

    smartcall ISPConfig Developer ISPConfig Developer


    I'm glad I helped.

    :mad: BEWARE :mad: when upgrading the panel. Looks like adding fields to forms leads to installation issues. Look here
    All my sites dissapeared.
    And looks like a database dump->deletion of additions->upgrade->restore additions is the right way.
  7. xrat

    xrat Member

    That's a bummer. Thanks for the pointer. I have already subscribed myself to that thread. See you there.
  8. vogelor

    vogelor ISPConfig Developer ISPConfig Developer

    can't find...

    Can anybody please help me!
    i found a general tutorial about php4 php5 and suphp but i can't find the tutorial for suPHP AND ISPConfig. I also don't find any check box or else to tell ISPConfig, that i use suPHP (i only found suExec).

    maybe i am too silly or it is too late form me today...
  9. xrat

    xrat Member

    There is no checkbox. And, I do not know of an official howto. But you should be fine with following the howto in for setting up suPHP in general. Once you have it running you can tell ISPconfig to enable suPHP for your virtual hosts by setting
    to suphp. This variable is to be found in which should be at /home/admispconfig/ispconfig/lib/


Share This Page