Install cURL for PHP in Linux

In case you need to use cURL, this is how you can install it. It also shows how to solve: Call to undefined function curl_init()...

1881 views

Edited: 2017-03-13 17:08

To install cURL you can type a simple command in the terminal. cURL can be installed with apt-get, so all you would have to do is to type the below in a terminal window:

sudo apt-get install php5-curl

The sudo part of the above gives you the necessary administrative privileges, using apt-get without sudo might result in an error.

After installing cURL you should also restart Apache to make it work.

sudo service apache2 restart

If cURL is not installed

A common error message when cURL is not installed on the server is something like the below:

Call to undefined function curl_init() in blah/blah/blah on line xx

The solution is to install cURL using the terminal, as mentioned in the top of this article.

Tell us what you think:

  1. Guide to mounting remote folders with SSHFS over SFTP, streaming media like local files, using Dolphin safely, avoiding root, and handling transfers with SCP and SSH keys.
  2. Understanding file permissions in Unix / Linux based systems, and how to make files immutable.
  3. In this article I will explain how to enable a swapfile on small instances, and why it might be useful, even if you do have enough physical memory.
  4. How to determine an optimal value for pm.max_children and related php-fpm settings for your server and web applications.
  5. Tutorial showing how to configure a VirtualBox Guest VM with HOST-only and NAT adapter, while using the WWW folder from the HOST OS.

More in: Linux servers