phpwindowsapachecurldll

How to enable PHP's cURL extension on Apache 2.4 PHP 8.4.6 And Win64


I have the following setup:

I've made minimal changes to both php.ini and httpd.conf

I tried enabling PHP's cURL extension by uncommenting extension=curl, and it was unable to load, showing no errors in Apache's log, but these couple of lines in PHP's errors log:

[28-Apr-2025 14:09:51 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'curl' (tried: C:\php\ext\curl (The specified module could not be found), C:\php\ext\php_curl.dll (The specified module could not be found)) in Unknown on line 0
[28-Apr-2025 14:09:52 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'curl' (tried: C:\php\ext\curl (The specified module could not be found), C:\php\ext\php_curl.dll (The specified module could not be found)) in Unknown on line 0

Things I made sure of:

  1. The path to PHP's cURL C:\php\ext\php_curl.dll is in fact correct and is accessible (other extensions are being loaded just fine)
  2. There are no missing dependencies for php_curl.dll (Tested them with a dependencies checker and had no errors)
  3. PHP's path is in the system path and is given top priority Apache's bin directory is in the system path and is right under PHP's path

Things I've tried: I tried manually adding the DLLs files hoping this might solve the issue

LoadFile "C:/php/libssl-3-x64.dll"
LoadFile "C:/php/libcrypto-3-x64.dll"
LoadFile "C:/Apache24/bin/zlib1.dll"

I had a similar issue with SQLite3 and it was solved by including libsqlite.dll (Before I had Apache's bin directory added to PATH) And that completely solved that issue! So I tried the same but no luck

I read older answers to this issue and most of them suggest upgrading Apache and/or PHP, but I've installed the latest versions and I don't think downgrading will solve the issue, nor am I interested in downgrading at this point.

And one very important note, cURL is indeed loaded in PHP's cli and I was able to use it whiteout any issue, it's just not working when loaded with Apache.


Solution

  • It turned out to be a mistake on my end, even though I've added PHP and Apache to PATH, I added them to the user's PATH variable, which will not be recognized when running Apache as a service.

    So I ended up adding them to the System's PATH variable and everything worked just fine.