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.

GD library and PHP 5 issue?

Discussion in 'General Discussion' started by jackbwa, Oct 19, 2010.

  1. jackbwa

    jackbwa Member

    Joined:
    May 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    I have a site that contains GD library and works fine with PHP 4, but after upgrading to PHP 5, the GD library doesn't work anymore.
    Is there any method to make PHP 5 works with GD library, Or I must
    return to work with PHP 4?

    thanks in advance
     
  2. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Joined:
    Nov 5, 2008
    Messages:
    2,557
    Likes Received:
    7
    Trophy Points:
    38
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Is the GD module compiled into PHP 5? GD can be selected when building PHP via EasyApache.

    What is the output from the following command (via root SSH access)?
    Code:
    # /usr/local/bin/php -m | grep -i gd
     
  3. jackbwa

    jackbwa Member

    Joined:
    May 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Yes,I select GD when compiling the PHP. the result of the above ssh line is "gd". but all the the pictures disappear from my homepage, If I recompile GD with PHP 4 it works again.
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Do you have the system set to use both PHP 4 and PHP 5 on it? If you do not, you could compile both PHP 4 and PHP 5 that way with GD, then use PHP 4 as the default.

    Where I'm going with this is that after setting it up like that with both PHP 4 and PHP 5 compiled in EasyApache, then you could open a ticket and we could troubleshoot what's going on without it disrupting the site for long (since you won't have to keep recompiling). We can simply using an .htaccess to temporarily switch you to PHP 5 to try to see the cause of the issue.

    To open a ticket, you could either use WHM > Support Center > Contact cPanel or the link in my signature.
     
  5. jackbwa

    jackbwa Member

    Joined:
    May 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Thaks for your answer, I recompiled again with PHP 4 and PHP 5 and went to the account
    where the site that uses the GD library and changed the PHP configuration to PHP 4, and it's
    working fine.

    Now I'm going to submit a support ticket so you can check this issue.

    my last question, in the php configuration page, the selected option is "system default", so what
    is the default, I mean is it PHP 4 or PHP5? because if it's PHP 5 I will not change them,
    and if it's PHP 4 then i will need to change "system default" to PHP 5 in all my accounts.
    Or where can i find what is my system default or change it?

    thanks in advance
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    In WHM > Apache Configuration > PHP and SuEXEC Configuration area, the default PHP is whatever PHP version you select (PHP 4 or PHP 5). If you want your sites to mainly be PHP 5, then you can choose PHP 5, but the one site having issues with GD will then need to set the PHP handler to PHP 4 in the .htaccess file. Something like this should work:

    Code:
    AddType application/x-httpd-php4 .php
     
  7. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Joined:
    Nov 5, 2008
    Messages:
    2,557
    Likes Received:
    7
    Trophy Points:
    38
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Configuring and overriding the default PHP request handler via cPanel & WHM

    WebHost Manager can be used to set the PHP version that is used by default. While default PHP version set in WHM applies server-wide, please note that, as mentioned by cPanelTristan, it is possible to override the server-wide default by configuring a customized Apache .htaccess file, which may be placed within the document root (e.g., public_html) directory or any sub-directory therein. If affecting the default PHP version for an entire cPanel account is not desired, but rather needed only for a specific script (that has its own sub-directory), please keep in mind that more fine-grained control is possible by selectively placing the custom .htaccess file in only the specific directory where your PHP script is installed; this may be useful to avoid having a legacy PHP version affect the entire account and or to allow more time for migrating from or upgrading and modernizing out-of-date PHP scripts.

    For reference, here is the cPanel menu path where an end-user in can set a custom preference for which PHP version is used in their account (that will override the server-wide default): cPanel: Main >> Software/Services >> PHP Configuration

    Similarly, here is where the server-wide default can be set via WebHost Manager: WHM: Main >> Service Configuration >> Apache Configuration >> PHP and SuExec Configuration

    The server-wide default can be configured via command-line SSH access using the following utility:
    Related Documentation: Configuring PHP and suEXEC from the Command Line
    Code:
    # /usr/local/cpanel/bin/rebuild_phpconf --help
    Usage: /usr/local/cpanel/bin/rebuild_phpconf [--dryrun] [--no-restart] [--no-htaccess] [--current|--available] <Default PHP> <PHP4 Handler> <PHP5 Handler> <Suexec>
     --dryrun       : Only display the changes that would be made
     --no-restart   : Don't restart Apache after updating the php.conf link
     --no-htaccess  : Don't update user configurable PHP mime mapping.
     --current      : Show current settings
     --available    : Show available handlers and PHP SAPIs
     <Default PHP>  : Version of PHP to set as default handler for .php files
     <PHP# Handler> : Type of Apache module to use in serving PHP requests
     <Suexec>       : enabled, disabled, 1 or 0
    Command-line (CLI) Examples (of setting the server-wide default PHP version via root SSH access):
    • Set PHP 5 as the default, using suPHP as the request handlers for both PHP 5 and 4, with suEXEC enabled
      Code:
      # /usr/local/cpanel/bin/rebuild_phpconf 5 suphp suphp 1
    • Set PHP 4 as the default, using suPHP as the request handlers for both PHP 5 and 4, with suEXEC enabled
      Code:
      # /usr/local/cpanel/bin/rebuild_phpconf 4 suphp suphp 1

    When an end-user overrides the PHP version using cPanel, an Apache .htaccess file will be created in the user's home directory. The contents of this .htaccess file, as setup by cPanel, may resemble one of the following examples and will be located at a path like /home/username/.htaccess, where "username" represents the cPanel account username:
    Code:
    # Use PHP4 as default
    AddHandler application/x-httpd-php4 .php
    Code:
    # Use PHP5 as default
    AddHandler application/x-httpd-php5 .php
    The aforementioned Apache .htaccess file will exist if the preference was customized via cPanel, and can be viewed using a number of methods, including via the cPanel File Manager, cPanel Web Disk (WebDAV), FTP, SFTP, and SSH access. The following commands may be used via command-line (SSH) access, while ensuring to replace "username" with the actual cPanel account username:
    Code:
    # cat -en ~username/.htaccess
    # grep -Hn '' ~username/.htaccess
     
  8. jackbwa

    jackbwa Member

    Joined:
    May 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Thank you cPanelDon for your full explain and also my thanks to cPanelTristan , everything is working great now.
     
    #8 jackbwa, Oct 20, 2010
    Last edited: Oct 20, 2010
Loading...

Share This Page