Fatal error: Call to undefined function: curl_init()

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

You might also enjoy:

  • LAMP (Linux, Apache, mySQL and PHP) is a popular open source web development platform that uses Linux as its operating system, Apache as the web server, myS ...
  • The easiest way to set up a custom PHP 404 error page under Apache is to make use of the .htaccess file, a system file that allows you to override some of t ...
  • How do I configure IIS 6.0 to allow .exe files to be downloaded? IIS 6.0, when it was first released, was a lot more locked down than previous versions ...
  • If you've ever tried to do an ASP include using the following sort of input line, , on an IIS web server and you've come up short, the 500.100 error message ...
  • When handling file uploads via enctype="multipart/form-data" forms in PHP, you'll be pleased to know that PHP doesn't just leave you high and dry but instea ...

About Craig Lotter

Craig Lotter is an established web developer and application programmer, with strong creative urges (which keep bursting out at the most inopportune moments) and a seemingly insatiable need to love all things animated. Living in the beautiful coastal town of Gordon's Bay in South Africa, he games, develops, takes in animated fare, trains under the Funakoshi karate style and for the most part, simply enjoys life with his amazing wife and daughter. Oh, and he draws ever now and then too.
This entry was posted in Technology & Code, Tutorials and tagged client url library, curl, daniel stenberg, library, . Bookmark the permalink.
    blog comments powered by Disqus