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.
- Login to WHM and open the main page of WHM where it shows various Sections
- Locate or Search “Software” Section and Open it
- Open “EasyApache 4” (or EasyApache 3 if you are still using it)
- Tap on Customize for Current Installed Packages ( With EA3, it can be a bit different but a similar option will be present)
- After current package opens navigate to “PHP Extensions” menu in the left pane.
- 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)
- Tick on Install option.
- Now move to “Review” Section on Left Pane and long list opens.
- Under Green box, it will show that our php-curl will be installed under the current profile and we tap on Save Provision Option below the list.
- The installation progress starts and finishes successfully.
- Verify the extension by repeating Steps #2 to #6 and it should show a blue dot and installed box right next to it.
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