Tag Archives: curl

Ubuntu: How to Install cURL via a Terminal CodeUnit 21 AUG 2012

The cURL library is a useful tool that allows you to connect and communicate to many different types of servers with many different types of protocols. If you implement a cURL operation in your PHP code and the web page spits out a “Fatal error: Call to undefined function: curl_init()” error message back at you, then it is probably safe to assume that the cURL library is currently included in your Apache, PHP stack.

(To verify this, run a phpinfo() call and then search for ‘curl’. If it isn’t installed, then the search should return nothing).

To install cURL in Ubuntu 12.04 using a terminal, enter:

sudo apt-get install curl libcurl3-dev php5-curl
sudo service apache2 restart

If the status messages returned after the two operations have completed look all successful, rerun your phpinfo() call and you should now be able to find a couple of curl entries on the resulting page.


Fatal error: Call to undefined function: curl_init() CodeUnit 24 JUN 2009

PHPPretty damn useful: Client URL Library, or cURL for short. From the pages of PHP.net:

PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP’s ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.

If however you keep getting the error message Fatal error: Call to undefined function: curl_init() when you try running a PHP script or two on your server, then I’m afraid you currently don’t have this great little library enabled and as such, really should think about installing it ASAP.

So how do you do it?

Well first, let’s make sure that our diagnosis is in fact correct. Whip up a quick check page by creating a .php file with a phpinfo(); command in it and upload it to your server. Browse to file’s URL and search for ‘curl’ on the resulting page. If cURL support is enabled, then there will definitely be a listing for it.

If however it doesn’t appear on the page, you’ll need to go about enabling it yourself. Of course, if you are with a hosting company and not in control of the server yourself, simply ask them to do it for you! :)

Otherwise, if you are running a linux-based system, you need to ensure that your PHP is compiled with cURL support and the libcurl library needs to be installed. To install the php5-curl package, run sudo apt-get install php-curl and then restart the Apache web server with sudo /etc/init.d/apache2 restart.

If you are running a Windows-based system, cURL can be enabled by simply editing the php.ini file to remove the semi-colon in front of the extension=php_curl.dll line and then restarting the web server service/application.

(Note: If you get an error Unable to Load X:/path/php/ext/php_curl.dll error, locate and copy the ssleay32.php and libeay32.dll (OpenSSL) libraries to your system32 folder.)