Tuesday, February 9, 2010

Bookmark and Share

[HowTo] Install Curl in PHP5 and Apache

April 19, 2009 by Ivan  
Filed under Ubuntu

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.

Bookmark and Share

Related Post(s)

Comments

11 Responses to “[HowTo] Install Curl in PHP5 and Apache”
  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.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!