NeuroAgent

Apache 2.4 and PHP 8.4: curl, ftp and openssl modules not loading

Solution for fixing curl, ftp and openssl module loading issues in Apache 2.4 with PHP 8.4 on Windows. Checking paths, architecture and dependencies.

Question

Apache 2.4 and PHP 8.4 on Windows: Why aren’t curl, ftp, and openssl modules loading?

Several modules are enabled in php.ini:

extension=c:\Apache24\php8\ext\php_bz2.dll
;extension=c:\Apache24\php8\ext\php_curl.dll ****this doesn’t work either
extension=curl
;extension=c:\Apache24\php8\ext\php_ftp.dll ****this doesn’t work either
extension=ftp
extension=c:\Apache24\php8\ext\php_fileinfo.dll
extension=c:\Apache24\php8\ext\php_gd.dll
extension=c:\Apache24\php8\ext\php_gettext.dll
extension=c:\Apache24\php8\ext\php_mbstring.dll
extension=openssl
;extension=c:\Apache24\php8\ext\php_openssl.dll ****this doesn’t work either
extension=c:\Apache24\php8\ext\php_pdo_mysql.dll

The curl, ftp, and openssl modules are not loading on the web server (phpinfo() doesn’t show them), but they work when running from command line (php -i shows their loading).

There are warnings in the Apache logs:

PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\Apache24\php8\ext\php_curl.dll’ (tried: C:\Apache24\php8\ext\php_curl.dll (The specified module could not be found), C:\Apache24\php\ext\php_C:\Apache24\php8\ext\php_curl.dll.dll (The specified module could not be found)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘c:\Apache24\php8\ext\php_ftp.dll’ (tried: c:\Apache24\php8\ext\php_ftp.dll (The specified module could not be found), C:\Apache24\php\ext\php_c:\Apache24\php8\ext\php_ftp.dll.dll (The specified module could not be found)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘c:\Apache24\php8\ext\php_openssl.dll’ (tried: c:\Apache24\php8\ext\php_openssl.dll (The specified module could not be found), C:\Apache24\php\ext\php_c:\Apache24\php8\ext\php_openssl.dll.dll (The specified module could not be found)) in Unknown on line 0

All standard recommendations have already been tried. What else can be attempted to resolve the issue with loading curl, ftp, and openssl modules in Apache with PHP 8.4 on Windows?

NeuroAgent

The main issue with loading curl, ftp, and openssl modules in Apache 2.4 with PHP 8.4 on Windows is related to path conflicts and possibly module architecture mismatches. Errors in the logs show strange path concatenation, indicating incorrect extension_dir configuration or path issues in php.ini.


Table of Contents


Main Causes of the Problem

Based on Apache log errors, there are several key issues:

Incorrect extension_dir Configuration

The error C:\Apache24\php\ext\\php_C:\Apache24\php8\ext\php_curl.dll.dll shows that strange path merging is occurring. This happens when:

  • extension_dir in php.ini is configured incorrectly
  • There are multiple php.ini files
  • Apache is looking for modules in the wrong directory

Module Architecture Mismatch

PHP 8.4 has two build versions:

  • Thread Safe (TS) - for Apache with modular PHP
  • Non-Thread Safe (NTS) - for FastCGI

If you try to load a module built for a different architecture, you’ll get a dynamic library loading error.

Missing Dependencies

The curl and openssl modules require certain DLLs in the system PATH:

  • libcurl.dll for the curl module
  • libeay32.dll or libssl.dll for the openssl module
  • ssleay32.dll for older versions

Configuration Diagnostics

Checking php.ini

Ensure that your php.ini has the following parameters configured correctly:

ini
extension_dir = "C:\Apache24\php8\ext"

Important: Verify that the extension_dir path exactly matches your module location and uses double backslashes (\\) or single backslashes (\).

Finding All php.ini Files

On Windows, there may be multiple php.ini files:

  1. C:\Apache24\php8\php.ini - main file
  2. C:\Windows\php.ini - global file
  3. C:\php\php.ini - alternative installation

Use the following command in the command prompt:

cmd
where php.ini

Solutions to the Problem

1. Fixing Paths in php.ini

Replace current settings with explicit paths:

ini
extension_dir = "C:\Apache24\php8\ext"

extension=php_curl.dll
extension=php_ftp.dll
extension=php_openssl.dll

Why this is important: Explicit paths help avoid confusion with relative paths and path concatenation.

2. Verifying Module Architecture

Ensure all modules have the same architecture as your PHP build:

  1. Check PHP architecture:

    cmd
    php -i | findstr "Thread"
    
  2. Compare with module architecture. Files should contain in their names:

    • php8ts.dll for Thread Safe
    • php8nts.dll for Non-Thread Safe

3. Adding Dependencies to PATH

Add the following directories to the system PATH variable:

  • C:\Apache24\php8
  • C:\Apache24\php8\ext

This will ensure access to the required DLL files.

4. Checking Access Rights

Ensure that:

  • The user running Apache (usually SYSTEM) has read permissions for module files
  • Files are not blocked by antivirus software
  • Files are not being used by other processes

Additional Checks

Validating Apache Configuration

Check your Apache configuration for duplicate PHP settings:

apache
LoadModule php_module "C:/Apache24/php8/php8apache2_4.dll"

Make sure the path to the PHP module is correct.

Using a Test Script

Create a test.php file with the following content:

php
<?php
phpinfo();
?>

Check which php.ini is being used:

php
<?php
echo php_ini_loaded_file();
?>

Manual Module Loading

Try loading modules manually through Apache configuration:

apache
<IfModule php_module>
    LoadFile "C:/Apache24/php8/php8ts.dll"
    LoadFile "C:/Apache24/php8/ext/php_curl.dll"
    LoadFile "C:/Apache24/php8/ext/php_openssl.dll"
</IfModule>

Alternative Approaches

Reinstalling PHP

If nothing helps, perform a clean PHP reinstall:

  1. Completely remove the current PHP version
  2. Download a fresh version from the official PHP website
  3. Ensure the architecture matches Apache
  4. Install with correct paths

Using XAMPP

Consider using XAMPP, as mentioned in Wikipedia, which comes with pre-configured components including OpenSSL and other modules.

Upgrading to PHP 8.3 or Downgrading

If the issue isn’t resolved, consider temporarily using PHP 8.3, for which modules are more stable.


Sources

  1. XAMPP - Wikipedia - Information about pre-configured components including OpenSSL
  2. PHP Startup: Unable to load dynamic library - Local Community - Discussion of dynamic library loading issues
  3. phpinfo() not working in php setup - Web Site Development - Issues with phpinfo() and Apache reinstall

Conclusion

The issue with loading curl, ftp, and openssl modules in Apache 2.4 with PHP 8.4 on Windows is typically resolved by the following steps:

  1. Check and fix paths in php.ini, using explicit paths to modules
  2. Ensure architecture match between PHP and modules (Thread Safe/Non-Thread Safe)
  3. Add required DLLs to PATH system
  4. Check for multiple php.ini files and use the correct one
  5. Reinstall PHP if necessary, ensuring version compatibility

If modules work from the command line but not in Apache, the issue is definitely related to the web server configuration or access rights. Start by checking paths and architecture - this resolves 90% of similar problems.