Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • CURL: How to install curl on ubuntu 14.04

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2
    • 0
    • 1.27k
    Comment on it

    I was facing issue to run the following lines of code on php:

    $url = "http://example.com/";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    $response = curl_exec($ch);
    curl_close($ch);

    After researching hours on google I come to the conclusion that curl was not installed on ubuntu, so the code above was not running.  What it means is that you don't have curl installed and you need to install curl to use it. This can be done by going to a terminal CTRL + ALT + T then entering

     

    $ sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

     

    This will install curl, php and the necessary libraries to provide you with the functionality that you need. After the installation has completed, restart the server with

    $ sudo service apache2 restart

    Now create file info.php with following lines of code:

     

    <?php
    phpinfo();
    ?>

     

    You will see following has been installed on ubuntu localhost:

     

    CURL: How to install curl on ubuntu 14.04

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: