KevInSol
KevInSol

Reputation: 2644

PHP Startup: Unable to load dynamic library 'pdo_mysql' CLI only, apache OK - FreeBSD

As per the title, I'm getting PHP Startup: Unable to load dynamic library 'pdo_mysql' when I run /usr/local/bin/php from the command line, but it works fine as an Apache module.

PHP 8.4 running on FreeBSD 14.

./configure \
--with-apxs2=/usr/local/apache/bin/apxs \
--without-pdo-sqlite --without-sqlite3 --without-iconv \
--with-config-file-path=/usr/local/etc \
--enable-bcmath --without-cdb \
--enable-gd --without-iodbc  \
--without-gdbm --with-ndbm --without-db2 --without-dbm \
--without-readline --with-openssl \
--without-db3 --enable-dba \
--with-curl \
--with-jpeg --enable-calendar \
--with-mhash --enable-mbstring=all \
--with-zlib \
--enable-exif --with-zip \
--with-mysqli=mysqlnd --with-freetype --with-pdo-mysql


 # grep pdo /usr/local/etc/php.ini
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
; https://php.net/pdo-odbc.connection-pooling
;pdo_odbc.connection_pooling=strict
pdo_mysql.default_socket=

Full error:

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/local/lib/php/extensions/no-debug-zts-20240924/pdo_mysql (Cannot open "/usr/local/lib/php/extensions/no-debug-zts-20240924/pdo_mysql"), /usr/local/lib/php/extensions/no-debug-zts-20240924/pdo_mysql.so (Cannot open "/usr/local/lib/php/extensions/no-debug-zts-20240924/pdo_mysql.so")) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/local/lib/php/extensions/no-debug-zts-20240924/pdo_mysql (Cannot open "/usr/local/lib/php/extensions/no-debug-zts-20240924/pdo_mysql"), /usr/local/lib/php/extensions/no-debug-zts-20240924/pdo_mysql.so (Cannot open "/usr/local/lib/php/extensions/no-debug-zts-20240924/pdo_mysql.so")) in Unknown on line 0

Extensions directory it's trying is correct as per phpinfo() and there is no PDO files there.

So, I went to install it via pear and get invalid package name/package file "pdo-mysql"

I searched pear.php.net for 'pdo' and 'mysql' and cannot find anything remotely like pdo_mysql

Upvotes: 0

Views: 46

Answers (1)

Alex Howansky
Alex Howansky

Reputation: 53626

So, I went to install it via pear and get invalid package name/package file "pdo-mysql"

Note you've used a dash here, not an underscore. The proper name of the module is pdo_mysql.

You probably don't need that though. It looks like you're compiling yourself, and you've indicated that you want this module to be included statically:

--with-pdo-mysql

This means that it will be built-in to the main executable and there won't be a separate load-time module that needs to be referenced in the INI file.

If you want to compile dynamically (which will give you that pdo_mysql.so file), then you need to do:

--with-pdo-mysql=shared

However, in this case, I think your easiest solution is to just comment out the extension=pdo_mysql line. Since you've compiled statically, the module is already present and enabled.

Then run php -m from the command line and/or phpinfo() from a script to see what modules are live.

Upvotes: 4

Related Questions