php4 and php5 with suphp

Discussion in 'Installation/Configuration' started by smartcall, Dec 3, 2006.

  1. smartcall

    smartcall New Member

    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

    with:

    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.

    Regards,

    Apostol
     
  2. smartcall

    smartcall New Member

    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'){
    if($web["php_5"]){
    $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.

    Regards,

    Apostol
     
  3. falko

    falko Super Moderator Howtoforge Staff

    Looks nice! I've copied your solution to the Tips/Tricks forum!
     

Share This Page