linux中如何通过php.ini添加扩展?

发布于 2022-09-07 08:50:44 字数 15436 浏览 15 评论 0

在编译安装的时候,我只通过了以下命令来安装,然后我想像windows中那样修改 php.ini 就开启了扩展

./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

拷贝下载的php-7.2.6文件中的扩展文件

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

然后去修改完 php.ini 文件,开启了以下扩展

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

运行报错 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪也成诗 2022-09-14 08:50:44

1、你在Windows可以这样操作的前提是你的系统里面已经安装了相关的php扩展库,所以你能够通过修改php.ini的方式来开启或关闭这些php扩展库
2、你现在在Linux里面并没有安装上述的php扩展库,从报错Unable to load dynamic library里面可以得知
3、在Linux里面安装扩展的方法,不是修改php.ini后会自动安装的,如果你用的是Ubuntu,那么就使用 apt install php-common,apt install php-pdo,apt install php-mbstring,逐个添加上述PHP扩展库

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文