curl command is part of the operating system: install or update it with dnf install curl and check it with curl --version. PHP’s cURL extension, which WordPress, WHMCS and most payment plugins need, is installed per PHP version in WHM > EasyApache 4 (package ea-phpXX-php-curl). Check it with php -m | grep -i curl.The two kinds of cURL
| cURL command-line tool | PHP cURL extension | |
|---|---|---|
| What it is | A program you run in the shell and in scripts | A PHP module that lets PHP code make web requests |
| Used by | Administrators, cron jobs, install scripts | WordPress, WooCommerce, WHMCS, payment and API plugins |
| Installed with | The operating system package manager | EasyApache 4, for each PHP version |
| Updated by | System updates | EasyApache 4 package updates |
Install or update the cURL command
# AlmaLinux, Rocky Linux, CloudLinux
dnf install -y curl
# Development headers, only if you compile software against libcurl
dnf install -y libcurl-devel
curl --version
cURL is installed on almost every server already. Keep it updated with your normal system updates, because cURL security fixes arrive through the operating system packages. Do not compile cURL from source on a cPanel server; it can conflict with the system libraries.
Install the PHP cURL extension in WHM
- Log in to WHM as root and open Software > EasyApache 4.
- Click Customize next to the currently installed packages.
- Open PHP Extensions and search for
curl. - Turn on
ea-phpXX-php-curlfor every PHP version your sites use, for exampleea-php83-php-curl. - Click Review, then Provision.
You can install the same packages over SSH:
dnf install -y ea-php83-php-curl ea-php84-php-curl
/scripts/restartsrv_apache_php_fpm
On CloudLinux servers that use PHP Selector, account owners can also turn the extension on themselves in Select PHP Version. See our PHP Selector guide.
Check that PHP cURL works
# For one PHP version
/opt/cpanel/ea-php83/root/usr/bin/php -m | grep -i curl
# Show the libcurl version PHP uses
/opt/cpanel/ea-php83/root/usr/bin/php -r "print_r(curl_version()['version']);"
To check from a website, create a temporary info.php file with <?php phpinfo();, open it in the browser, search for “curl”, then delete the file.
Useful cURL commands for server work
curl -I https://example.com/ # headers only: status code, redirects, cache
curl -L -o file.zip https://example.com/file.zip # follow redirects and save to a file
curl -v https://example.com/ # full connection details, useful for SSL problems
curl --resolve example.com:443:203.0.113.10 https://example.com/ # test a new server before DNS
curl -X POST -d "name=test" https://example.com/form # send form data
A simple PHP cURL request
<?php
$ch = curl_init('https://api.example.com/status');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
if ($response === false) {
echo 'cURL error: ' . curl_error($ch);
}
curl_close($ch);
Always set a timeout, so a slow remote service cannot hold your PHP processes.
Use cURL safely in scripts
- Never turn off certificate checks with
-korCURLOPT_SSL_VERIFYPEER = falsein production. Fix the certificate problem instead. - Keep API keys out of the command line, where other users can see them in the process list. Read them from a protected file instead.
- Download install scripts to a file and read them before you run them, rather than piping them straight into bash.
Troubleshooting
| Error | Likely cause | Fix |
|---|---|---|
| Call to undefined function curl_init() | The PHP cURL extension is not installed for the site’s PHP version | Install ea-phpXX-php-curl for that version, or enable it in Select PHP Version. |
| curl: (60) SSL certificate problem | Outdated CA certificates, or the remote site has a bad certificate | Update the system with dnf update ca-certificates, then check the remote certificate. |
| curl: (7) Failed to connect | A firewall blocks outgoing connections | Check the server firewall’s outgoing rules, for example TCP_OUT in CSF. |
| curl: (6) Could not resolve host | DNS resolution problem on the server | Check /etc/resolv.conf and test with dig example.com. |
Need help with this?
Need PHP extensions installed or a server tuned? Our server management team can do it for you.
Frequently asked questions
How do I check if cURL is enabled in PHP?
Run php -m | grep -i curl for the PHP version your site uses, or look for the curl section in a phpinfo() page.
Do I need to restart anything after installing PHP cURL?
EasyApache 4 restarts the services it needs. If you install over SSH, restart PHP-FPM with /scripts/restartsrv_apache_php_fpm.
Can I install cURL on shared hosting?
The cURL command and the PHP extension are already installed on our shared hosting servers. On CloudLinux, check Select PHP Version.
How do I update cURL for a security fix?
Run your normal system updates, for example dnf update curl libcurl. cPanel PHP packages update through EasyApache 4.
Why does WordPress say cURL is missing?
The site’s PHP version does not have the cURL extension. Install it for that version in EasyApache 4.
Related guides