PHP Fatal error: Call to undefined function curl_init()

I recently set up a development server in a VirtualBox VM running Ubuntu server 11.04. My plan was to move a development database and website to this VM and migrate away from a local XAMPP installation on a Windows box. The only problem is that Apache and PHP were not exactly the same between the two systems. This resulted in some of my scripts not working correctly. More specifically, I was getting the “PHP Fatal error:  Call to undefined function curl_init()” error. On my Ubuntu VM.

This likely meant that curl was not installed or enabled on Ubuntu, so here’s what I did:

  1. Run this command from a terminal:
    • sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
  2. Make sure curl is enabled in your php.ini. This file is usually in “/etc/php5/apache2/php.ini”
    • In the section for dynamic extensions add (or uncomment):
      • extension=php_curl.so
  3. Restart Apache:
    • sudo /etc/init.d/apache2 restart
Be Sociable, Share!