TECH / Servers & Websites 2 min read

PHP Error: Call to Undefined Function curl_init() – How to Fix

Antonio NEMCD Author
Published Oct 14, 2012 · 2 min

The error Fatal error: Call to undefined function curl_init() means your script tried to make an outbound HTTP request, but the cURL extension isn’t installed or enabled in PHP.

PHP error Call to undefined function curl_init()

On shared hosting, enabling cURL is usually a single checkbox in your hosting panel (PHP Version / Extensions) or a quick support ticket. If you manage your own VPS or server, here are the exact commands for each platform.

Step 1. Check Your PHP Version and Loaded Modules

Start by confirming the active PHP version and whether curl is loaded:

php -v
php -m | grep -i curl

Remember that CLI PHP and web PHP (PHP-FPM or Apache mod_php) often run different versions or separate php.ini files. Always confirm which version serves your site via phpinfo().

Step 2. Install or Enable php-curl

  • Debian / Ubuntu: install the matching package for your PHP version (for example php8.3-curl or php-curl):
sudo apt update
sudo apt install php8.3-curl
  • Rocky Linux / AlmaLinux / Fedora: cURL ships with php-common:
sudo dnf install php-common
  • FreeBSD: install the binary package for your PHP branch (back in the PHP 5 days we compiled /usr/ports/ftp/php52-curl from ports, while today pkg takes two seconds):
pkg install php83-curl
  • Windows (XAMPP / WAMP / standalone PHP): open php.ini, find ;extension=curl, and remove the leading semicolon so it reads extension=curl.

Step 3. Restart PHP-FPM or Apache

Reload your web stack so running workers load the new extension:

sudo systemctl restart php8.3-fpm
# or for Apache:
sudo systemctl reload apache2

As soon as the service reloads, curl_init() starts working – and when provisioning a fresh server, installing php-curl, php-mbstring, php-xml, and php-zip together right up front saves a lot of repeat troubleshooting.

Related posts:

Leave a Comment