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.

Enable user to choose default PHP version in cPanel?

Discussion in 'General Discussion' started by peconi, Mar 4, 2009.

  1. peconi

    peconi Active Member

    Joined:
    Mar 27, 2005
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Hi guys,

    I have both PHP4 and PHP5 compiled via Easy Apache 3 on the latest version of cPanel.

    I set PHP4 to run as FCGI and PHP5 via DSO.

    In cPanel clients cannot see the dropdown which lets them choose the default PHP version (as in the attached picture).

    All I see in its place is the text saying: "These PHP configuration settings are customizable by the server administrator. They are listed for reference only."

    Any help on how to enable this would be greatly appreciated!
     

    Attached Files:

  2. arunsv84

    arunsv84 Well-Known Member

    Joined:
    Oct 20, 2008
    Messages:
    373
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    127.0.0.1
    cPanel Access Level:
    Root Administrator
    Im not sure how to setup in cpanel. But if you have root access you can follow the steps listed below to set php version to each user according to their need.

    STEPS:

    1.You can find your server's active php.ini file by
    running phpinfo.php file.

    Code:
    <?php
    phpinfo();
    ?>
    and then copy the php.ini to the public_html folder.

    2. Create a CGI script

    Now create a small script and put it in your public_html directory. Create a file name "php4.cgi" or "php5.cgi" and put the following into it:

    Code:
    #!/bin/sh
    exec /usr/local/cpanel/cgi-sys/php4,5  -c /home/username/public_html/php.ini
    The above php4,5 can be replaced with the version you wish to run.

    3. Modify the .htaccess file

    Add this one line to your .htaccess file:

    Code:
    Action application/x-httpd-php4,5 /php4,5.cgi
    This tells Apache to perform an action each time it encounters a file of
    file type "application/x-httpd-php5" — if you're using a version of PHP
    older than PHP5, you'll need to change this to "application/x-httpd-php"
    (or upgrade to PHP5 — ask your webhost).

    4. Test your site

    Load up your website and see if it works.

    Cheers!!! :)
     
  3. peconi

    peconi Active Member

    Joined:
    Mar 27, 2005
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Hmm, this all actually makes sense, however it is not working for me.

    When I call .php file, it's still parsed with PHP5 instead of PHP4.

    I copied the PHP4 php.ini into my public_html (the one that phpinfo() in php.php4 file reported).

    My PHP file (php.php):
    Code:
    <?php phpinfo(); ?>
    My php4.cgi (with chmod +x):
    Code:
    #!/bin/sh
    exec /usr/local/cpanel/cgi-sys/php4 -c /home/peconi/public_html/php.ini
    
    My .htaccess file:
    Code:
    Action application/x-httpd-php /php4.cgi
    
    I go to my php.php, and it still shows PHP5 as the main parser.... Odd...

    Any help would be appreciated!
     
  4. peconi

    peconi Active Member

    Joined:
    Mar 27, 2005
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    It seems that this part is the problem:

    Code:
    Action application/x-httpd-php /php4.cgi
    It's like if it gets skipped or something.

    When I change it to:
    Code:
    Action application/x-httpd-php5 /php4.cgi
    The PHP5 files do not get parsed but are offered to be downloaded instead.
     
  5. arunsv84

    arunsv84 Well-Known Member

    Joined:
    Oct 20, 2008
    Messages:
    373
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    127.0.0.1
    cPanel Access Level:
    Root Administrator
    Change the following

    Code:
    Action application/x-httpd-php5 /php4.cgi
    to

    Code:
    Action application/x-httpd-php4 /php4.cgi
    and try.
     
  6. arunsv84

    arunsv84 Well-Known Member

    Joined:
    Oct 20, 2008
    Messages:
    373
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    127.0.0.1
    cPanel Access Level:
    Root Administrator
    #6 arunsv84, Mar 6, 2009
    Last edited: Mar 6, 2009
Loading...

Share This Page