Bookmark and Share

April 19, 2009 by Ivan  

[HowTo] Install Curl in PHP5 and Apache

Ads by Google

PHP LogoThis 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

If  you found this post usefull please leave me any comment. Thanks, and have a nice day.

What people search:

Reader 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. 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.

  3. baibulat says:

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

  4. Ivan says:

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

  5. 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?

  6. Ivan says:

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

  7. 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

  8. 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.

  9. Gauti says:

    Hi Ivan,

    Thanks that sorted the problem out.

  10. Michael P. says:

    thanks dude ;)

  11. palaniraja says:

    sudo apt-get install curl php5-curl

    does it for me.

  12. Minnie says:

    Thanks so much!!

  13. henrik says:

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

  14. 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.

  15. Ivan,

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

    Many Thanks!

  16. 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

  17. Katlunera says:

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

  18. Shalkam says:

    worked with me
    THANK YOU

  19. 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!

  20. Jomy says:

    Thanks that was a big help.

  21. Robert says:

    Good tutorial,

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

    Thank you very much :)

  22. Lulu says:

    Very useful to enable a joomla plug-in

  23. Duc says:

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

  24. Sftranna says:

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

  25. Sftranna says:

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

  26. i wonder if you using IIS or apache?

Please do not add HTML tags in your comments. All comments are moderated.

Add a comment

(required, use real name)
(required, will not be published)
(optional, will not be published)
blog comments powered by Disqus