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

1840 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. Understanding file permissions in Unix / Linux based systems, and how to make files immutable.
  2. 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.
  3. How to determine an optimal value for pm.max_children and related php-fpm settings for your server and web applications.
  4. Tutorial showing how to configure a VirtualBox Guest VM with HOST-only and NAT adapter, while using the WWW folder from the HOST OS.
  5. You may have wondered what the /etc/php/8.0/conf.d/ directory is for in Debian and Ubuntu, and whether it is better to edit the conf.d files than editing php.ini directly; find out in this Tutorial.

More in: Linux servers