[SOLVED]Call to undefined function curl_init() | WHM

Category : cPanel/WHM

Facing Fatal error: Call to undefined function curl_init() on your cPanel Server with the websites hosted on it?

This is due to missing PHP Extention named php-curl on the PHP Version which your website is using.

In this guide we will  fix “undefined function curl_init()” by installing phpXX-php-curl (XX here is PHP version) via WHM.

Requirements

  • WHM/cPanel on Server and its WHM Credentials

Procedure

  1. Login to WHM and open the main page of WHM where it shows various Sections
  2. Locate or Search “Software” Section and Open it
  3. Open “EasyApache 4” (or EasyApache 3 if you are still using it)
  4. Tap on Customize for Current Installed Packages ( With EA3, it can be a bit different but a similar option will be present)
  5. After current package opens navigate to “PHP Extensions” menu in the left pane and long list opens.
  6. In the search bar, you have to search for curl and select to install.
    Make sure you filter the PHP version you are using and need for particular PHP Version (In case you want to install for every user, then you can select all the PHP versions)
  7. Tick on Install option and make it as below image
  8. Now move to “Review” Section on Left Pane
  9. Under Green box, it will show that our php-curl will be installed under current profile and we tap on Save Provision Option below the list.
  10. The installation progress starts and finishes successfully.
  11. Verify the extension by repeating Steps #2 to #6 and it should show a blue dot and installed box right next to it like our image below.verify php extention

So, with this, we have finished installing php-curl which will eventually fix “undefined function curl_init()” error for users on that server. Using the same method we can Install and uninstall other PHP Extensions.

 

For LAMP setup users with PHP 7.0, a simple command will install the required missing extension :

sudo apt install php7.0-curl