Skip to content

Instantly share code, notes, and snippets.

@alecos71
Last active December 16, 2023 02:46
Show Gist options
  • Save alecos71/de26b0079b963a690e798375b8561dfa to your computer and use it in GitHub Desktop.
Save alecos71/de26b0079b963a690e798375b8561dfa to your computer and use it in GitHub Desktop.
How to fix errors generated by PHP 7.4 related to CURL & SQLite3 under Windows

Fix for CURL & SQLite3 under Windows on PHP 7.4

If you have just downloaded and configured PHP 7.4 and you want to use CURL and SQLite3 you could run into a serious PHP-generated error for the reason that both CURL and SQlite3 make use of an external library located in the PHP directory. First SQLite3 was integrated into PHP but from version 7.4 no longer. The errors are these:

PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite'

PHP Warning: PHP Startup: Unable to load dynamic library 'sqlite3'

PHP Warning: PHP Startup: Unable to load dynamic library 'php_curl'

CURL depends on the libssh2.dll library whereas SQLite3 depends on the libsqlite3.dll library. Below are the instructions to solve the problem definitively.

To enable CURL and SQLite3 on Windows with PHP 7.4 first edit httpd.conf (Apache) and add the following lines:

# load php.ini from chosen directory
Define SRVROOT "F:/Apache24"
ServerRoot "${SRVROOT}"
PHPIniDir "${SRVROOT}/php"

# load PHP Core library on Windows
LoadFile "${SRVROOT}/php/php7ts.dll"
LoadFile "${SRVROOT}/php/libpq.dll"

# load CURL library on Windows
LoadFile "${SRVROOT}/php/libssh2.dll"

# load SQLite3 library on Windows
LoadFile "${SRVROOT}/php/libsqlite3.dll"

# load PHP 7.4 module on Windows
LoadModule php7_module "${SRVROOT}/php/php7apache2_4.dll"

Then edit php.ini (PHP) and uncomment like below:

extension=curl
extension=pdo_sqlite
extension=sqlite3

Now CURL and SQLite3 are enabled and working fine under Windows using PHP 7.4

@sergeykuzmin
Copy link

Thank you, bro!!!

@yuretc-oguretc
Copy link

Thank you so much!!!!

@MansourAbiRizk
Copy link

Thank you :D

@Eccenux
Copy link

Eccenux commented Mar 9, 2023

Thanks. A bit more universal based on above:

##
#BEGIN PHP
Define MY_PHP_ROOT "c:/PHPs/PHP74"

AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html

# ini
PHPIniDir "${MY_PHP_ROOT}/"

# Load library required by CURL
LoadFile "${MY_PHP_ROOT}/libssh2.dll"

# load PHP 7 module on Windows
LoadModule php7_module "${MY_PHP_ROOT}/php7apache2_4.dll"
#END PHP
##

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment