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.

How to enable curl in PHP for 2082/2083 accesses

Discussion in 'cPanel Developers' started by nesanjoseph, Sep 15, 2011.

  1. nesanjoseph

    nesanjoseph Active Member

    Joined:
    Dec 31, 2010
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    I am trying to put some pages to be accessed within cpanel console [2082/2083] and I use curl requests in my php files. But unfortunately, PHP curl did not work. I noticed in phpinfo() output that curl is not enabled while configuring php [./configure].

    Could you please help in enabling curl for the cPanel console accessed through 2082/2083 ports? I searched web and got some links that told to enable this from WHM console [Main >> Software >> Easy Apache (Apache Update) >> ....] . But I tried enabling curl, curlssl, mcrypt etc and rebuilt the config and ran it. But this did not change anything in 2082/2083 port access.

    Awaiting your help.

    Many thanks in advance,
    Nesan Joseph R.
     
  2. pusan1983

    pusan1983 Member

    Joined:
    Aug 31, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
  3. nesanjoseph

    nesanjoseph Active Member

    Joined:
    Dec 31, 2010
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    Thanks for the response. I already tried that and it said PHP & Apache have been updated successfully. I enabled curl But I could not see any change in the end user cPanel console [accessed via 2082/2083 port].

    1) In the first step, I kept the default radio selected [Previously Saved Config (** DEFAULT **) ] and clicked the button "Start customizing based on the profile".
    2) In step 2, I chose "Apache 2.2 "
    3) In step 3, I chose "PHP 5" alone [checkbox]
    4) In step 4, I chose "5.3.8" [PHP version]
    5) In step 5, did not do any change and clicked the button "Exhaustive Options list"
    6) In step 6, selected the checkboxes for the following things additionally : Curl, CurlSSL, Curlwrappers, Mcrypt
    7) Clicked "Save and build" button and confirmed the action by clicking "Yes".

    The progress ran for some minutes and said everything is done successful. But I could not see any difference in the 2082/2083 access page.

    Please correct me if I need to do some more things.

    Many thanks,
    Nesan Joseph R.
     
  4. pusan1983

    pusan1983 Member

    Joined:
    Aug 31, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    ok, i created a simple script for you:

    <?php
    $dom_u = ""; //username
    $dom_p = ""; //password
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_BUFFERSIZE, 131072);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    curl_setopt($ch, CURLOPT_URL, "http://www.domain.com:2082"); //domain
    curl_setopt($ch, CURLOPT_USERPWD,$dom_u.":".$dom_p);
    $data = curl_exec($ch);
    $info = curl_getinfo($ch);
    print_r($info["http_code"]);
    curl_close($ch);
    ?>

    this script will give you http status code. it should give 200(if it gives 200, it means: everythings okay). well, if you got any curl error, please let us know which kind of error you get

    regards
     
  5. nesanjoseph

    nesanjoseph Active Member

    Joined:
    Dec 31, 2010
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    I receive the following error:

    Fatal error: Call to undefined function curl_init() in /tmp/cpanel_phpengine.1316188149.18814sKW7jq7zCI on line 4

    NOTE: I created a file my.php [with your content] in "/usr/local/cpanel/base/frontend/x3/test/" folder and accessed the following in browser:
    https://<mycpanelserver>:2083/cpsess9967124545/frontend/x3/test/my.php

    Thank you very much for your kind help! :)

    Nesan Joseph R.
     
    #5 nesanjoseph, Sep 15, 2011
    Last edited: Sep 15, 2011
  6. nesanjoseph

    nesanjoseph Active Member

    Joined:
    Dec 31, 2010
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    6
    Hi pusan1983,

    I received an alert email and you have said the following suggestion:

    **removed quote that had wrong information**

    I saw from phpinfo() that php.ini is read from "/usr/local/cpanel/3rdparty/etc/". I opened the file "/usr/local/cpanel/3rdparty/etc/php.ini" and found that the entry you have mentioned was missing. I even put that entry [uncommented] and restarted HTTP Server, but no luck!

    I did the changes as you have suggested in the following files too [because I am not sure what ini file this is using].

    /usr/lib/php.ini
    /usr/local/lib/php.ini
    /usr/local/cpanel/scripts/php.ini

    And restarted Apache web server from WHM. But no luck. :(

    What may be the problem? Can I give more details so that you can help me?

    Thanks,
    Nesan Joseph R
     

    Attached Files:

    #6 nesanjoseph, Sep 15, 2011
    Last edited by a moderator: Sep 15, 2011
  7. 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
    I had deleted the prior post as it had wrong information about the dll entry in php.ini file. Windows uses dll files and Linux/FreeBSD do not. Please do not uncomment lines with dll in them in the php.ini files. That recommendation is erroneous and can cause PHP to cease working on your machine with internal server errors in pages.
     
  8. nesanjoseph

    nesanjoseph Active Member

    Joined:
    Dec 31, 2010
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    6
    Oh! I too forgot to think! I had reverted the changes now. Thanks. I will wait for some more suggestions.
     
Loading...

Share This Page