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

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介: linux中如何通过php.ini添加扩展? 在编译安装的时候,我只通过了以下命令来安装,然后我想像windows中那样修改 php.ini 就开启了扩展 ./configure \ --enable-fpm \ --with-fpm-user=www-data \ --with-fpm-gro.

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

在编译安装的时候,我只通过了以下命令来安装,然后我想像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

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扩展库

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
Linux PHP
linux centos7 安装php7.4 实测 遇到的坑
linux centos7 安装php7.4 实测 遇到的坑
50 0
|
2月前
|
存储 算法 Shell
【Shell 命令集合 扩展命令】Linux cksum 命令使用教程
【Shell 命令集合 扩展命令】Linux cksum 命令使用教程
34 0
|
2月前
|
存储 Unix Linux
【Shell 命令集合 扩展命令】Linux chgrp命令使用教程
【Shell 命令集合 扩展命令】Linux chgrp命令使用教程
36 1
|
2月前
|
存储 Shell Linux
【Shell 命令集合 扩展命令】Linux chattr命令使用教程
【Shell 命令集合 扩展命令】Linux chattr命令使用教程
37 1
|
2月前
|
存储 安全 Shell
【Shell 命令集合 文件管理】Linux显示和修改文件或目录的扩展属性 lsattr命令使用教程
【Shell 命令集合 文件管理】Linux显示和修改文件或目录的扩展属性 lsattr命令使用教程
49 0
|
10天前
|
编译器 API PHP
深入PHP扩展开发:打造高效自定义模块
【4月更文挑战第30天】 在追求性能优化和特定功能实现的道路上,PHP提供了一种强大机制——扩展。本文将引导读者通过编写一个简单的PHP扩展来探索扩展开发的世界。我们将涉及从环境搭建到代码实现,再到扩展的编译与加载的完整流程,确保读者能够理解并实践如何创建高效的自定义PHP模块。
|
10天前
|
安全 Linux
【亮剑】`chattr`是Linux中用于管理文件和目录扩展属性的命令,影响文件系统处理方式
【4月更文挑战第30天】`chattr`是Linux中用于管理文件和目录扩展属性的命令,影响文件系统处理方式。常用属性包括:`a`(追加)、`i`(不可变)、`s`(安全删除)和`S`(同步更新)。通过`chattr [选项] <模式> <文件或目录>`设置属性,如`chattr +i <文件名>`使文件不可变,`-i`移除不可变属性。`lsattr`用于查看属性。注意,只有root用户有权更改属性,不是所有文件系统都支持所有属性,且更改关键文件属性前应备份。`chattr`有助于提升系统安全性和数据保护。
|
1月前
|
监控 Linux 应用服务中间件
linux php-fpm优化 php-fpm.conf 重要参数详解
linux php-fpm优化 php-fpm.conf 重要参数详解
12 0
|
1月前
|
关系型数据库 Linux PHP
linux 编译安装php7.2 实测!!
linux 编译安装php7.2 实测!!
14 0
|
1月前
|
NoSQL Linux PHP
php添加redis扩展 linux和windos图文详解 l
php添加redis扩展 linux和windos图文详解 l
4 0