SitePoint Sponsor

User Tag List

Results 1 to 15 of 15

Thread: help with cURL

  1. #1
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Exclamation help with cURL

    Hello,
    I was wondering and hoping someone could help me figure out what cURL package to install. Well, first, I have a script that I am running in part of an app that I built with PHP and that script uses cURL. My hosting provider says he has installed cURL because he can use it from the command-line, yet I get the error that the script made if cURL is not installed.

    Here is the part of the script that checks and uses cURL:
    PHP Code:
                     // start curl up.
            // if no curl, hit an error.
            
    if(!function_exists('curl_init')){
                
    $this->error('CURL is not installed on this hosting account. Please contact your hosting provider and ask for it to be enabled.',true);
            }else{
                
    $this->ch curl_init();
                
    curl_setopt($this->chCURLOPT_RETURNTRANSFERtrue);
                @
    curl_setopt($this->chCURLOPT_FOLLOWLOCATIONtrue);
                
    curl_setopt($this->chCURLOPT_USERAGENT"Mozilla/4.0 (compatible; PHP Website Search)");
                
    curl_setopt($this->chCURLOPT_HEADER0);
            } 
    Now, when I use the app on my testServer running MAMP, it works fine, but when I run it on my real-server I get the error that is above in the code if the curl_init function does not exist, which means that cURL is not installed.

    But, as I mentioned before, my hosting provider said that cURL is installed. He also said, all of the libcurl packages are installed". He said that after I suggested that he installed those after finding this and this via a quick Google Search for PHP cURL Package.

    Does anyone know or have any suggestions on what cURL package I need to tell my hosting provide to install to get the PHP script working? (debian squeeze package)

    I would really appreciate any and all suggestions!

    Thanks in Advance & Best Regards,
    Team 1504.

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,287
    Mentioned
    182 Post(s)
    Tagged
    4 Thread(s)
    Are you sure the issue is not simply a PATH problem?

    If you have SSH access to the server, try "whereis" to locate the installed cURL.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Path to what? cURL? I never write a path to cURL in the code above.

    I dont have ssh access. The hosting provider does. What should I tell him to do to check or fix a PATH problem? He said he can use cURL from the command line (idk what that means)

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2011
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is one thing to install curl on the server, but PHP also needs to be configured with cURL.

    To use PHP's cURL support you must also compile PHP --with-curl[=DIR] where DIR is the location of the directory containing the lib and include directories.
    http://www.php.net/manual/en/curl.installation.php

    If you do phpinfo(), do you see --with-curl in the configuration? If not, your host needs to configure PHP with it.

  5. #5
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Well, I talked to my hosting provider and he said that he said he is uncomfortable recompiling PHP because that puts his site as well as others on the server at risk.

    Also since Debian does it themselves and they would do what it is best, there is no need to re-do it especially just for me.

    Are they any other solutions or possibilities? No packages that one can install? Because the hosting provider keep on asking for that.

  6. #6
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Is there any mention of cURL when you do:
    PHP Code:
    <?php
    print_r
    (get_loaded_extensions());
    phpinfo();

  7. #7
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    @team1504

    If worse comes to worse, ask him what Virtual Machine he runs for his hosting and if you create a properly compiled VM then would he consider firing it up and testing it on his server array. You then have to create a Debian VM with properly compiled php and upload it to you ISP.

    It would be easier to move to a new host that does support CURL though.

    Steve
    ictus==""

  8. #8
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Cups View Post
    [...]
    PHP Code:
    <?php
    print_r
    (get_loaded_extensions());
    phpinfo();
    Nice the print_r(get_loaded_extensions()) is good
    ictus==""

  9. #9
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ServerStorm View Post
    @team1504

    If worse comes to worse, ask him what Virtual Machine he runs for his hosting and if you create a properly compiled VM then would he consider firing it up and testing it on his server array. You then have to create a Debian VM with properly compiled php and upload it to you ISP.

    It would be easier to move to a new host that does support CURL though.

    Steve
    Yes it would be easier, but this host is a friend of mine. Thats also why i have the ability to contact him so much. We tried a package that someone suggested called php5-curl, but that didn't seem to work.

    Here is the approved and selected answer on a Q/A site that has to do a similar question:
    No you don't need to recompile.

    there 3 different ways to enable/install php5-curl extension on Ubuntu. all of them are easy. here is the link to that. http://php.net/manual/en/install.pecl.php last 3 options starting with 'compiling...' all works for you. apply any of them. get curl.so file in extensions directory of php installation. then edit related extension line in php.ini file. restart the apache.
    To which my host / friend emailed me: "Ah, "php5-curl". That was the package name I needed. Try it now."
    But it doesn't seem to be working.

    So now i have 2 questions:

    1.) Should he have done something else? Does anyone think that answer, above from the Q/A site, is a good solution?
    2.) Do you or does anyone think anyone on the PHP forum, here, would help me rewrite the part of the script that uses cURL so that it uses something that is supported?

  10. #10
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    Is there any mention of cURL when you do:
    PHP Code:
    <?php
    print_r
    (get_loaded_extensions());
    phpinfo();
    I do not think I see it. Here is a link to it. What does that mean? I hope not bad news.

  11. #11
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    No, cURL is clearly not installed or enabled for this server -- as far as PHP is concerned.

    So, you will have to continue to support your support ( :| ) team, or think of another way round the problem you seem to have.

    There are alternatives to using cURL on PHP.

    I see that server has allow_url_fopen() turned "on", which is a security setting mnay shared hosted suppliers used to turn off, as far as I know.

    Why are you so keen to install cURL anyway?

  12. #12
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by team1504 View Post
    I do not think I see it. Here is a link to it. What does that mean? I hope not bad news.
    Cups is onto a good question about what you need to do?

    If you decide you want to continue to pursue CURL with PHP then here is a decent small page on php that gives the 'nuts and bolts': http://php.net/manual/en/install.unix.debian.php. Given that this is a friend of yous some of this may be easier.
    Code:
      gunzip php-NN.tar.gz
      tar -xf php-NN.tar
      cd ../php-NN  ./configure --with-mysql --with-curl  
      make  
      make install
    Hope this helps
    Steve
    ictus==""

  13. #13
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question

    I mentioned Cups and ServerStorm just to separate my replies to there posts, but please feel free to read the entire post as it sums things up in

    @Cups :
    Quote Originally Posted by Cups View Post
    No, cURL is clearly not installed or enabled for this server -- as far as PHP is concerned.
    I was afraid it meant that.

    So, you will have to continue to support your support ( :| ) team, or think of another way round the problem you seem to have.
    Quote Originally Posted by Cups View Post
    There are alternatives to using cURL on PHP.

    I see that server has allow_url_fopen() turned "on", which is a security setting mnay shared hosted suppliers used to turn off, as far as I know.
    i will check into that. Thank you for telling me!
    Would you be willing to help me get the script to use url_fopen() instead of cURL if I showed the entire script and or just what i am trying to accomplish?

    Quote Originally Posted by Cups View Post
    Why are you so keen to install cURL anyway?
    Because the script, that I bought because I could not come up with something myself, apparently needs it as the snippet of it above returns the error when i run in on my live server.
    And I thought that the easiest way to fixing the problem would be to install cURL, but so far no packages are working and my host is not keen on recompling PHP. And the original author, form whom i bought it from, has not replied and its been 3 weeks. And I just asked for general help so i am summing he doesn't check that email anymore.


    @ServerStorm :
    Off Topic:

    First, I love the neuron avatar!

    Quote Originally Posted by ServerStorm View Post
    Cups is onto a good question about what you need to do?

    If you decide you want to continue to pursue CURL...
    What this entire script is, is a search-engine for my site. I spent many night trying to write my own, but could not come up with anything. (More is explained in the earlier section of the post).

    I am starting to think that using something besides cURL is the option left.

    Does anyone have any clues / can anyone help me replace the parts of the script that use cURL with url_fopen() as that seems to be enabled? or if possible remove the cURL parts of the script.
    I should warn you that it is quite messy.
    I know I am asking for a lot, but if anyone would be willing to give any help, I would sincerely appreciate it!

    Thanks in Advance & Best Regards,
    Team 1504

  14. #14
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    php alternatives to curl

    From what you are saying it seems you are going out to one of the search engines maybe? ... and pulling back search results of your own site?

  15. #15
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    from what i read through the code that seems like what part of it is doing?

    Do you or anyone know how i / we could make a search engine in PHP that does not contact Google or something already functioning and just takes the $_Post[] of an input and displays a list of the instances where that word(s) is found in the specified url? the suer would not be able to define or change the url, but the programmer in the code.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •