[HowTo] Install Curl in PHP5 and Apache

curl-libcurl

This time i want to share with you how to install Curl in PHP5 in Linux Environtment (I’m using Ubuntu 8.10) and using apache web server, but if you have any question to install php-curl in other environment, feel free to contact me of leave any comment, i will glad to help you.

Okay, now let’s start with check if php-curl is already installed in your server or not.

To check it please follow this step:

  1. Create a file in your web server (in Ubuntu it would be in /var/www folder), name it info.php
  2. Open that file and type this command:
    <?php phpinfo(); ?>
  3. Save that file
  4. Open your favorite browser and open that file (ex: http://localhost/info.php)
  5. Now you will see the Information about your PHP installation
  6. Search for Curl, and if you cannot find it, it mean your php doesn’t have curl installed.

To install php-curl please follow this steps:

  1. Open your terminal and type this command:
    sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt
  2. After it finish open php.ini file (mine is at /etc/php5/apache2/php.ini ) and add this command: extension=curl.so
  3. Save the file and restart apache with this command:
    /etc/init.d/apache2 restart
  4. Check the PHP information page again, you will find PHP-CURL installed
  5. That’s it

Most hosting providers today already have Curl installed on their server.

Recent Comments

  1. Jon Jennings says:

    Just a quick 'thank you' note for this.

    I was trying to replace file_get_contents() with curl in some code. Of course it worked on my hosting server but not on my server at home. A quick phpinfo() had shown me the reason why already but your post saved me 15 minutes searching through documentation.

    Thank you.

  2. Jon Jennings says:

    Just a quick ‘thank you’ note for this.

    I was trying to replace file_get_contents() with curl in some code. Of course it worked on my hosting server but not on my server at home. A quick phpinfo() had shown me the reason why already but your post saved me 15 minutes searching through documentation.

    Thank you.

  3. baibulat says:

    'Open your terminal and type this command'. It is not clear about what terminal mentioned there. If it said as windows explorer window, so it is ok. But the terminal is confusing most.

  4. baibulat says:

    ‘Open your terminal and type this command’. It is not clear about what terminal mentioned there. If it said as windows explorer window, so it is ok. But the terminal is confusing most.

  5. baibulat says:

    maybe to make some illustration or picture of the terminal, or the pathway, how to open this terminal…

    • Anonymous says:

      Terminal mean your shell. If you're a linux/unix user, you should familiar with the word "terminal".

  6. baibulat says:

    maybe to make some illustration or picture of the terminal, or the pathway, how to open this terminal…

    • Ivan says:

      Terminal mean your shell. If you’re a linux/unix user, you should familiar with the word “terminal”.

  7. Gauti says:

    I run the command and I get a lot of 404 errors.
    System indicates it needs to install extra packages and upgrade some. When it tries it show the 404 errors.
    I have minimal experience on *nix and don't have a clue what to do.

    Can you please suggest a way forward?

  8. Gauti says:

    I run the command and I get a lot of 404 errors.
    System indicates it needs to install extra packages and upgrade some. When it tries it show the 404 errors.
    I have minimal experience on *nix and don’t have a clue what to do.

    Can you please suggest a way forward?

  9. Anonymous says:

    Hi Gauti,
    Which step produce 404 error?
    What OS are you using? Because that command only run on Ubuntu/Debian.

  10. Ivan says:

    Hi Gauti,
    Which step produce 404 error?
    What OS are you using? Because that command only run on Ubuntu/Debian.

  11. Gauti says:

    I am using Ubuntu OS.
    PHP 5.2.6.2

    I get 404's for many of the PHP5 libraries being upgraded and also the curl libraries. The errors are similar to the ones below –

    Err http://security.ubuntu.com intrepid-security/main linux-libc-dev
    Err http://security.ubuntu.com intrepid-security/main lib-ssl-dev

    • Anonymous says:

      Hi Gauti,
      looks like your repo is not update.
      Try this steps:
      1. sudo apt-get autoclean
      2. sudo apt-get update
      3. sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt
      Hope this help.

  12. Gauti says:

    I am using Ubuntu OS.
    PHP 5.2.6.2

    I get 404’s for many of the PHP5 libraries being upgraded and also the curl libraries. The errors are similar to the ones below –

    Err http://security.ubuntu.com intrepid-security/main linux-libc-dev
    Err http://security.ubuntu.com intrepid-security/main lib-ssl-dev

    • Ivan says:

      Hi Gauti,
      looks like your repo is not update.
      Try this steps:
      1. sudo apt-get autoclean
      2. sudo apt-get update
      3. sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt
      Hope this help.

  13. Gauti says:

    Hi Ivan,

    Thanks that sorted the problem out.

  14. Gauti says:

    Hi Ivan,

    Thanks that sorted the problem out.

  15. Michael P. says:

    thanks dude ;)

  16. Michael P. says:

    thanks dude ;)

  17. palaniraja says:

    sudo apt-get install curl php5-curl

    does it for me.

  18. palaniraja says:

    sudo apt-get install curl php5-curl

    does it for me.

  19. Minnie says:

    Thanks so much!!

  20. Minnie says:

    Thanks so much!!

  21. henrik says:

    where in my php.ini file should I put line command: extension=curl.so

    • Anonymous says:

      @henrik,
      search your php.ini file with 'extension=' keyword.
      You will see bunch of extension command there.
      You can add it there.
      Cheers.

  22. henrik says:

    where in my php.ini file should I put line command: extension=curl.so

    • Ivan says:

      @henrik,
      search your php.ini file with 'extension=' keyword.
      You will see bunch of extension command there.
      You can add it there.
      Cheers.

  23. Ivan,

    I am installing an ecommerce package on a new Ubuntu 10.04 server and your instructions worked perfectly.

    Many Thanks!

  24. Ivan,

    I am installing an ecommerce package on a new Ubuntu 10.04 server and your instructions worked perfectly.

    Many Thanks!

  25. Dan says:

    Thanks!

    This worked perfectly on Debian 5. I got terrible confused when I was installing magento and it asked for curl..

    Many thanks

  26. My Pleasure :)

  27. Katlunera says:

    great post!!! Very helpful!!
    Thanks a lot!
    Carolina

  28. Shalkam says:

    worked with me
    THANK YOU

  29. Tom says:

    You just saved my life….
    One other thing: I did not have sudo installed… bummer, but I found this url:
    http://www.debianhelp.co.uk/sudo.htm that helped me to install sudo. After that, all your steps were right to the point!

  30. Jomy says:

    Thanks that was a big help.

  31. Robert says:

    Good tutorial,

    as I’m new at ubuntu it was very helpful :).

    Thank you very much :)

  32. Lulu says:

    Very useful to enable a joomla plug-in

  33. Duc says:

    Thanks for the tip. Just what I needed for my paypal processing.

  34. Sftranna says:

    hey i need to configure curl for windows but cant…………

  35. Sftranna says:

    hey i need to configure curl for windows but cant…………

  36. i wonder if you using IIS or apache?

  37. Abc says:

    thansk – the curl dev is important – else other mods fail to find the headers

  38. Misho says:

    Thank you very much! You help a lot.

  39. Geoff Liddiard says:

    Terimakasih! I got some errors on restarting apache, but it seems to be working fine.

  40. Latifani2 says:

    i will lick to no more about the terminal commands and there are mining tans to u.. i hope to here if u… my name is lamptey from ghana email:latifani2@yahoo.com

  41. Cesar says:

    Hi Ivan
    Nice page,
    I try to develop a facebook aplication in a free hosting but it shows "Facebook needs the CURL PHP extension." what can be? thanks

  42. iBoston says:

    I LOVE YOU. YOU HAVE SAVED ME FROM JUMPING IN FRONT OF A TRUCK. I WAS ABOUT TO TAKE THIS COMPUTER AND THROW IT OUT THE WINDOW

  43. Nobody says:

    Hi, this was very usfull. Thank you, you saved me a lot of time!
    Kind Regards

  44. Nikhil says:

    Thanks! Was useful!

  45. Dev says:

    Awesome thanks mate

  46. Shekhara says:

    Hi,

    I am getting the following error, kindly help.

    ————–
    ]# sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt
    sudo: apt-get: command not found
    —————

    Thanks,
    AS

  47. Konrad Rowe says:

    Thanks alot, this saved me with installation of SugarCRm which needed the curl module enabled.

  48. Fedarik says:

    Worked perfectly for me .. thanks a ton.

  49. Cookie says:

    Hey!

    Thanks a lot for the help. I needed to enable curl for the WordPress Stats Dashboard.

  50. Shafiul says:

    Thanks… that's helpful. Another easy way is to install it using Ubuntu Software Center…

  51. Tobiash says:

    Thanks a lot for this easy to use config page!!

    Greetings from Sweden

  52. Dudu says:

    THX !

    Still a few issues I had to run " /etc/init.d/apache2 restart " with sudo (as a super user aka root)
    and the edit of "php.ini" was done using " sudo gedit php.ini " or directly using "sudo gedit /etc/php5/apache2/php.ini "

    THX !

  53. Tbotee says:

    thanks man, it worked

  54. Renhiei says:

    Hi,
    Just want to ask I follow the steps that you have.. but still i haven't install the cURL in my localhost it prompt me the below error.

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    libcurl3 is already the newest version.
    Package libcurl3-dev is a virtual package provided by:
    libcurl4-openssl-dev 7.18.0-1ubuntu2.2
    You should explicitly select one to install.
    E: Package libcurl3-dev has no installation candidate

    Please help I need this to install on my PC for testing purposes..
    thanks.

  55. Edsonx says:

    works fine, thx & merry christmas *<(:)-{)>

  56. M_rahman says:

    thanks
    for those trying to install lately with ubuntu and didn't work with them, try first
    sudo apt-get install curl php5-curl
    in many cases this will be enough, if not, then proceed with the line in the article above it should run with no errors now.

    it seems to me a broken dependency

  57. Manisha Patel says:

    I want to install Curl into windows environment so please help me

  58. Rajib Chatterjee says:

    thanks

  59. sudo aptitude install php5-curl

    works for me.

  60. Mikea says:

    Very useful thank you…

  61. Where do we type the command you mentioned? Do we do it in DOS?

  62. TARIK says:

    Thank you so much!

  63. ChrisN says:

    Thank you very much, easy to understand and works like a charm :)

  64. Mafia Rose says:

    Thanks!!!

  65. Murthy20785 says:

    Great Buddy, tanQ for this valuable information…now itz easy 4 me .

  66. Uptheground says:

    Veeery usefull, thanks for your valuable time.

  67. Serpiente says:

    Thank you very much, this article was useful for me

  68. Beautiful! I was looking for just thing. Apt-get makes it so easy!
    Thanks so much.

  69. Abhijeet says:

    i m using wamp server in windows but in my php curl is not present so how can i install for windows curl?

  70. Great… thanks!

  71. Target4Cactus says:

    For ubuntu server 11.04, the following works:

    sudo apt-get install curl php5-curl

    sudo /etc/init.d/apache2 restart

    @bd123731de183ad12418f24a53a579b9:disqus — Thanks :-)

  72. Guest says:

    Thank you, works fine on Debian Lenny!

  73. Kareeem_shams says:

    Please enter a valid URL. Protocol is required (http://, https:// or ftp://)

  74. Vaishak says:

    Been doing everything from building php and libcurl from source, configuring php with the separately built curl module…. But couldn't make my apache server point to this newly-built php-bundle. But your two lines of instructions did the job! Thanks man! Thanks a lot!

css.php