How to add extensions through php.ini in linux?

when compiling and installing, I only use the following command to install, and then I want to change php.ini as in windows to open the extension

./configure \
--enable-fpm \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--enable-soap \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd

$ make && make install

copy the extension file in the downloaded php-7.2.6 file

cp -r /opt/downloads/php-7.2.6/ext /usr/local/lib/

then modify the php.ini file and open the following extension

extension_dir = "/usr/local/lib/etc"
extension=bz2
extension=curl
;extension=fileinfo
extension=gd2
extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=interbase
;extension=ldap
extension=mbstring
;extension=exif      ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
extension=odbc
extension=openssl
extension=pdo_firebird
extension=pdo_mysql
extension=pdo_oci
extension=pdo_odbc;
extension=pdo_pgsql;
extension=pdo_sqlite
extension=pgsql
;extension=shmop

run php-fpm-t

[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "bz2" (tried: /usr/local/lib/ext/bz2 (/usr/local/lib/ext/bz2: cannot read file data: Is a directory), /usr/local/lib/ext/bz2.so (/usr/local/lib/ext/bz2.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "bz2" (tried: /usr/local/lib/ext/bz2 (/usr/local/lib/ext/bz2: cannot read file data: Is a directory), /usr/local/lib/ext/bz2.so (/usr/local/lib/ext/bz2.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "curl" (tried: /usr/local/lib/ext/curl (/usr/local/lib/ext/curl: cannot read file data: Is a directory), /usr/local/lib/ext/curl.so (/usr/local/lib/ext/curl.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "curl" (tried: /usr/local/lib/ext/curl (/usr/local/lib/ext/curl: cannot read file data: Is a directory), /usr/local/lib/ext/curl.so (/usr/local/lib/ext/curl.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "gd2" (tried: /usr/local/lib/ext/gd2 (/usr/local/lib/ext/gd2: cannot open shared object file: No such file or directory), /usr/local/lib/ext/gd2.so (/usr/local/lib/ext/gd2.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "gd2" (tried: /usr/local/lib/ext/gd2 (/usr/local/lib/ext/gd2: cannot open shared object file: No such file or directory), /usr/local/lib/ext/gd2.so (/usr/local/lib/ext/gd2.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "gettext" (tried: /usr/local/lib/ext/gettext (/usr/local/lib/ext/gettext: cannot read file data: Is a directory), /usr/local/lib/ext/gettext.so (/usr/local/lib/ext/gettext.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "gettext" (tried: /usr/local/lib/ext/gettext (/usr/local/lib/ext/gettext: cannot read file data: Is a directory), /usr/local/lib/ext/gettext.so (/usr/local/lib/ext/gettext.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "mbstring" (tried: /usr/local/lib/ext/mbstring (/usr/local/lib/ext/mbstring: cannot read file data: Is a directory), /usr/local/lib/ext/mbstring.so (/usr/local/lib/ext/mbstring.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "mbstring" (tried: /usr/local/lib/ext/mbstring (/usr/local/lib/ext/mbstring: cannot read file data: Is a directory), /usr/local/lib/ext/mbstring.so (/usr/local/lib/ext/mbstring.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "mysqli" (tried: /usr/local/lib/ext/mysqli (/usr/local/lib/ext/mysqli: cannot read file data: Is a directory), /usr/local/lib/ext/mysqli.so (/usr/local/lib/ext/mysqli.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "mysqli" (tried: /usr/local/lib/ext/mysqli (/usr/local/lib/ext/mysqli: cannot read file data: Is a directory), /usr/local/lib/ext/mysqli.so (/usr/local/lib/ext/mysqli.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "odbc" (tried: /usr/local/lib/ext/odbc (/usr/local/lib/ext/odbc: cannot read file data: Is a directory), /usr/local/lib/ext/odbc.so (/usr/local/lib/ext/odbc.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "odbc" (tried: /usr/local/lib/ext/odbc (/usr/local/lib/ext/odbc: cannot read file data: Is a directory), /usr/local/lib/ext/odbc.so (/usr/local/lib/ext/odbc.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "openssl" (tried: /usr/local/lib/ext/openssl (/usr/local/lib/ext/openssl: cannot read file data: Is a directory), /usr/local/lib/ext/openssl.so (/usr/local/lib/ext/openssl.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "openssl" (tried: /usr/local/lib/ext/openssl (/usr/local/lib/ext/openssl: cannot read file data: Is a directory), /usr/local/lib/ext/openssl.so (/usr/local/lib/ext/openssl.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "pdo_firebird" (tried: /usr/local/lib/ext/pdo_firebird (/usr/local/lib/ext/pdo_firebird: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_firebird.so (/usr/local/lib/ext/pdo_firebird.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "pdo_firebird" (tried: /usr/local/lib/ext/pdo_firebird (/usr/local/lib/ext/pdo_firebird: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_firebird.so (/usr/local/lib/ext/pdo_firebird.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "pdo_mysql" (tried: /usr/local/lib/ext/pdo_mysql (/usr/local/lib/ext/pdo_mysql: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_mysql.so (/usr/local/lib/ext/pdo_mysql.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "pdo_mysql" (tried: /usr/local/lib/ext/pdo_mysql (/usr/local/lib/ext/pdo_mysql: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_mysql.so (/usr/local/lib/ext/pdo_mysql.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "pdo_oci" (tried: /usr/local/lib/ext/pdo_oci (/usr/local/lib/ext/pdo_oci: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_oci.so (/usr/local/lib/ext/pdo_oci.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "pdo_oci" (tried: /usr/local/lib/ext/pdo_oci (/usr/local/lib/ext/pdo_oci: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_oci.so (/usr/local/lib/ext/pdo_oci.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "pdo_odbc" (tried: /usr/local/lib/ext/pdo_odbc (/usr/local/lib/ext/pdo_odbc: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_odbc.so (/usr/local/lib/ext/pdo_odbc.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "pdo_odbc" (tried: /usr/local/lib/ext/pdo_odbc (/usr/local/lib/ext/pdo_odbc: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_odbc.so (/usr/local/lib/ext/pdo_odbc.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "pdo_pgsql" (tried: /usr/local/lib/ext/pdo_pgsql (/usr/local/lib/ext/pdo_pgsql: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_pgsql.so (/usr/local/lib/ext/pdo_pgsql.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "pdo_pgsql" (tried: /usr/local/lib/ext/pdo_pgsql (/usr/local/lib/ext/pdo_pgsql: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_pgsql.so (/usr/local/lib/ext/pdo_pgsql.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "pdo_sqlite" (tried: /usr/local/lib/ext/pdo_sqlite (/usr/local/lib/ext/pdo_sqlite: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_sqlite.so (/usr/local/lib/ext/pdo_sqlite.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "pdo_sqlite" (tried: /usr/local/lib/ext/pdo_sqlite (/usr/local/lib/ext/pdo_sqlite: cannot read file data: Is a directory), /usr/local/lib/ext/pdo_sqlite.so (/usr/local/lib/ext/pdo_sqlite.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "pgsql" (tried: /usr/local/lib/ext/pgsql (/usr/local/lib/ext/pgsql: cannot read file data: Is a directory), /usr/local/lib/ext/pgsql.so (/usr/local/lib/ext/pgsql.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "pgsql" (tried: /usr/local/lib/ext/pgsql (/usr/local/lib/ext/pgsql: cannot read file data: Is a directory), /usr/local/lib/ext/pgsql.so (/usr/local/lib/ext/pgsql.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "soap" (tried: /usr/local/lib/ext/soap (/usr/local/lib/ext/soap: cannot read file data: Is a directory), /usr/local/lib/ext/soap.so (/usr/local/lib/ext/soap.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "soap" (tried: /usr/local/lib/ext/soap (/usr/local/lib/ext/soap: cannot read file data: Is a directory), /usr/local/lib/ext/soap.so (/usr/local/lib/ext/soap.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "sockets" (tried: /usr/local/lib/ext/sockets (/usr/local/lib/ext/sockets: cannot read file data: Is a directory), /usr/local/lib/ext/sockets.so (/usr/local/lib/ext/sockets.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "sockets" (tried: /usr/local/lib/ext/sockets (/usr/local/lib/ext/sockets: cannot read file data: Is a directory), /usr/local/lib/ext/sockets.so (/usr/local/lib/ext/sockets.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "sqlite3" (tried: /usr/local/lib/ext/sqlite3 (/usr/local/lib/ext/sqlite3: cannot read file data: Is a directory), /usr/local/lib/ext/sqlite3.so (/usr/local/lib/ext/sqlite3.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "sqlite3" (tried: /usr/local/lib/ext/sqlite3 (/usr/local/lib/ext/sqlite3: cannot read file data: Is a directory), /usr/local/lib/ext/sqlite3.so (/usr/local/lib/ext/sqlite3.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library "xmlrpc" (tried: /usr/local/lib/ext/xmlrpc (/usr/local/lib/ext/xmlrpc: cannot read file data: Is a directory), /usr/local/lib/ext/xmlrpc.so (/usr/local/lib/ext/xmlrpc.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library "xmlrpc" (tried: /usr/local/lib/ext/xmlrpc (/usr/local/lib/ext/xmlrpc: cannot read file data: Is a directory), /usr/local/lib/ext/xmlrpc.so (/usr/local/lib/ext/xmlrpc.so: cannot open shared object file: No such file or directory)) in <b>Unknown</b> on line <b>0</b><br />
[25-May-2018 08:24:59] NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful
Mar.14,2021

1. The premise that you can do this in Windows is that the relevant php extension libraries have been installed in your system, so you can turn on or off these php extension libraries
2 by modifying php.ini. You do not have the above php extension libraries installed in Linux. You can learn
3 from the error report Unable to load dynamic library. The method of installing extensions in Linux is not automatically installed after modifying php.ini. If you are using Ubuntu, then use apt install php-common,apt install php-pdo,apt install php-mbstring, to add the above PHP extension libraries one by one

Menu