如下,Centos里启动 php-fpm 时,控制台总在抛若干警告。
[root@aerchi] #service php-fpm start
Starting php-fpm daemon is success[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/curl (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/curl: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/curl.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/curl.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'bcmath.so' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/bcmath.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/bcmath.so: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/bcmath.so.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/bcmath.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'fileinfo' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/fileinfo (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/fileinfo: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/fileinfo.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/fileinfo.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'mbstring' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/mbstring (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/mbstring: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/mbstring.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/mbstring.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/mysqli (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/mysqli: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/mysqli.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/mysqli.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'openssl' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/openssl (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/openssl: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/openssl.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/openssl.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/pdo_mysql (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/pdo_mysql: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/pdo_mysql.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/pdo_mysql.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'bcmath.so' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/bcmath.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/bcmath.so: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/bcmath.so.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/bcmath.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'curl.so' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/curl.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/curl.so: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/curl.so.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/curl.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'fileinfo.so' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/fileinfo.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/fileinfo.so: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/fileinfo.so.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/fileinfo.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'json.so' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/json.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/json.so: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/json.so.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/json.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/mcrypt.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/mcrypt.so: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/mcrypt.so.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/mcrypt.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'phar.so' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/phar.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/phar.so: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/phar.so.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/phar.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/zip.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/zip.so: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-zts-20170718/zip.so.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[28-Nov-2018 17:45:40] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)
由于折腾 Centos主机不是很溜, 安装php时参考了别人的配置,编译php时没有开启若干扩展(很大的一个坑啊).
在实际使用中抛错了,再想添加扩展,然而不想卸载后再重装,这下就需要用到phpize来帮忙了。
比如增加bcmath扩展的支持,这是一个支持大整数计算的扩展。
由于windows系统是自带而且内置,linux“本类函数仅在 PHP 编译时配置了 --enable-bcmath 时可用”(引号内是手册中的话)
PHP 版本: php-7.2.11,
PHP源文件路径: /usr/local/src/php-7.2.11
PHP的安装后路径: /usr/local/php/
php.ini 文件路径: /etc/php.ini
对应的模块.ini 文件路径: /etc/php.d/
php-config 路径: /usr/local/php/bin/php-config
扩展模块安装路径: /usr/local/php/lib/php/extensions/no-debug-zts-20170718
解决方法:
首先,确保抛警告的模块都已经安装。
1. 进入源文件路径目录: cd /usr/local/src/php-7.2.11/ext
2. 进入bcmath目录(安装其它模块,换成其它模块名称即可): cd bcmath
3. 然后执行输入: /usr/local/php/bin/phpize
4. 然后再执行: ./configure --with-php-config=/usr/local/php/bin/php-config
5. 执行命令: make && make install
注:(基于安装bcmatch, 以上命令均在 /usr/local/src/php-7.2.11/ext/bcmath 下执行)
控制台操作步骤:
[root@aerchi ext]# cd /usr/local/src/php-7.2.11/ext/bcmath
[root@aerchi bcmath]# ls
bcmath.c config.m4 CREDITS package.xml tests
bcmath.lo config.w32 libbcmath php_bcmath.h
[root@aerchi bcmath]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20170718
Zend Module Api No: 20170718
Zend Extension Api No: 320170718
[root@aerchi bcmath]# ./configure --with-php-config=/usr/local/php/bin/php-config
...
...
config.status: creating config.h
[root@aerchi bcmath]# make && make install
...
...
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/src/php-7.2.11/ext/bcmath/modules
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/
以上,提示安装完成, 然后进入 /usr/local/php/lib/php/extensions/no-debug-zts-20170718/ 路径 下查看:
如下,模块安装完成,下面,来检查一下。
[root@aerchi ~]# /usr/local/php/sbin/php-fpm -t
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: /usr/local/php/lib/php/extensions/no-debug- zts-20170718/curl (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/curl: cannot open shared object file: No such file or directory), /usr/local/php/lib/ php/extensions/no-debug-zts-20170718/curl.so (/usr/local/php/lib/php/extensions/ no-debug-zts-20170718/curl.so: cannot open shared object file: No such file or d irectory)) in Unknown on line 0
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'bcmath' (tried: /usr/local/php/lib/php/extensions/no-debu g-zts-20170718/bcmath (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/b cmath: cannot open shared object file: No such file or directory), /usr/local/ph p/lib/php/extensions/no-debug-zts-20170718/bcmath.so (/usr/local/php/lib/php/ext ensions/no-debug-zts-20170718/bcmath.so: undefined symbol: _tsrm_ls_cache)) in U nknown on line 0
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'fileinfo' (tried: /usr/local/php/lib/php/extensions/no-de bug-zts-20170718/fileinfo (/usr/local/php/lib/php/extensions/no-debug-zts-201707 18/fileinfo: cannot open shared object file: No such file or directory), /usr/lo cal/php/lib/php/extensions/no-debug-zts-20170718/fileinfo.so (/usr/local/php/lib /php/extensions/no-debug-zts-20170718/fileinfo.so: undefined symbol: file_global s)) in Unknown on line 0
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'mbstring' (tried: /usr/local/php/lib/php/extensions/no-de bug-zts-20170718/mbstring (/usr/local/php/lib/php/extensions/no-debug-zts-201707 18/mbstring: cannot open shared object file: No such file or directory), /usr/lo cal/php/lib/php/extensions/no-debug-zts-20170718/mbstring.so (/usr/local/php/lib /php/extensions/no-debug-zts-20170718/mbstring.so: cannot open shared object fil e: No such file or directory)) in Unknown on line 0
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: /usr/local/php/lib/php/extensions/no-debu g-zts-20170718/mysqli (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/m ysqli: cannot open shared object file: No such file or directory), /usr/local/ph p/lib/php/extensions/no-debug-zts-20170718/mysqli.so (/usr/local/php/lib/php/ext ensions/no-debug-zts-20170718/mysqli.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'openssl' (tried: /usr/local/php/lib/php/extensions/no-deb ug-zts-20170718/openssl (/usr/local/php/lib/php/extensions/no-debug-zts-20170718 /openssl: cannot open shared object file: No such file or directory), /usr/local /php/lib/php/extensions/no-debug-zts-20170718/openssl.so (/usr/local/php/lib/php /extensions/no-debug-zts-20170718/openssl.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/local/php/lib/php/extensions/no-d ebug-zts-20170718/pdo_mysql (/usr/local/php/lib/php/extensions/no-debug-zts-2017 0718/pdo_mysql: cannot open shared object file: No such file or directory), /usr /local/php/lib/php/extensions/no-debug-zts-20170718/pdo_mysql.so (/usr/local/php /lib/php/extensions/no-debug-zts-20170718/pdo_mysql.so: cannot open shared objec t file: No such file or directory)) in Unknown on line 0
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'bcmath.so' (tried: /usr/local/php/lib/php/extensions/no-d ebug-zts-20170718/bcmath.so (/usr/local/php/lib/php/extensions/no-debug-zts-2017 0718/bcmath.so: undefined symbol: _tsrm_ls_cache), /usr/local/php/lib/php/extens ions/no-debug-zts-20170718/bcmath.so.so (/usr/local/php/lib/php/extensions/no-de bug-zts-20170718/bcmath.so.so: cannot open shared object file: No such file or d irectory)) in Unknown on line 0
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'fileinfo.so' (tried: /usr/local/php/lib/php/extensions/no -debug-zts-20170718/fileinfo.so (/usr/local/php/lib/php/extensions/no-debug-zts- 20170718/fileinfo.so: undefined symbol: file_globals), /usr/local/php/lib/php/ex tensions/no-debug-zts-20170718/fileinfo.so.so (/usr/local/php/lib/php/extensions /no-debug-zts-20170718/fileinfo.so.so: cannot open shared object file: No such f ile or directory)) in Unknown on line 0
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Invalid l ibrary (maybe not a PHP library) 'phar.so' in Unknown on line 0
[30-Nov-2018 17:09:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/local/php/lib/php/extensions/no-debu g-zts-20170718/zip.so (/usr/local/php/lib/php/extensions/no-debug-zts-20170718/z ip.so: undefined symbol: executor_globals), /usr/local/php/lib/php/extensions/no -debug-zts-20170718/zip.so.so (/usr/local/php/lib/php/extensions/no-debug-zts-20 170718/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[30-Nov-2018 17:09:32] NOTICE: configuration file /usr/local/php/etc/php-fpm.con f test is successful
(注:针对上面检查的问题,极有可能是php.ini 配置文件里没有启用扩展模块路径,见其次)
进入 php.ini 查看,抛错的正是启用的扩展模块.
其次, 在php.ini配置文件中,修改 extension_dir的路径(大概 730 行左右)及启用对应模块等。
如笔者的php 扩展模块路径为: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/
原始:
修改后:
最后,别忘记了重启php-fpm, 并重启nginx 或者apache,reload不行,一定要重启.
ps -ef|grep nginx # 查看nginx 进程
#php-fpm
pkill -9 php-fpm
service php-fpm stop
service php-fpm start
#nginx
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx -s reload
/usr/local/nginx/sbin/nginx //启动
#apache
apachectl stop
apachectl start
升级 php 7.2 后,使用微信提供的加解密代码时,提示 call to undefined function mcrypt_module_open() ;大脑疯狂运转1秒钟后,得出结论:php 7.2的扩展有变动;查阅相关资料知晓,mcrypt 扩展从 php 7.1.0 开始废弃;自 php 7.2.0 起,会移到 pecl。还好,安装过程不复杂。
环境:centos 7
yum 安装依赖包:
yum install libmcrypt libmcrypt-devel mcrypt mhash
apt-get install php-pecl
安装Libmcrypt
# cd /usr/local/src
# wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
# tar -zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# /usr/local/php5/bin/phpize #动态编译php模块,使其可以使用configure编译。
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
# libmcript默认安装在/usr/local
安装mhash
Mhash是基于离散数学原理的不可逆向的php加密方式扩展库,其在默认情况下不开启。mhash的可以用于创建校验数值,消息摘要,消息认证码,以及无需原文的关键信息保存(如密码)等。
# cd /usr/local/src
# wget https://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download
# tar -zxvf mhash-0.9.9.9.tar.gz
# cd mhash-0.9.9.9
# /usr/local/php5/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
安装mcrypt
Mcrypt 扩展库可以实现加密解密功能,就是既能将明文加密,也可以密文还原。PHP加密扩展库Mcrypt的算法和加密模式.
# cd /usr/local/src
---------------------
# wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
# tar -zxvf mcrypt-2.6.8.tar.gz
# cd mcrypt-2.6.8
或
# wget http://pecl.php.net/get/mcrypt-1.0.1.tgz
# tar xf mcrypt-1.0.1.tgz
# cd mcrypt-1.0.1
-------------------
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
安装完毕,按照编译安装后的提示
注:比如,zip, phar, fileinfo 模块安装也是类似, 只需将 解决方法 (2) 里的模块路径 分别换成 zip, phar, fileinfo, 并执行3、4、5步即可。
其它方法:
1. 打开/usr/local/php/bin/php-config注释掉:extension_dir='/usr/local/php/lib/php/extensions/no-debug-zts-20170718/'解决的
网上的解决方法是打开/usr/local/php/bin/php-config
注释掉:extension_dir='/usr/local/php/lib/php/extensions/no-debug-zts-20170718/',
但是无效,最终解决方式删除 /etc/php.d 下的对应的 .ini 报错文件!!!
2. 将/etc/php.d/ 目录下的.ini文件全部重命名为.so文件, 或删除对应的 *.ini 文件
如:cp /etc/php.d/zip.ini /etc/php.d/zip.so
若有扩展被重复加载了,打开/etc/php.ini文件,注释扩展加载的地方即可
vi /etc/php.ini # 将redis、memcache、swoo加载的地方注释即可
/etc/init.d/php-fpm restart
3. 其它:
PHP 目录结构:
1. build 和编译有关的目录。
2. ext 扩展库代码,例如 mysql、zlib、iconv 等我们熟悉的扩展库。其中/ext/standard/目录下是常用的标准函数集。
3. main 主目录包含主要的 PHP 宏和定义。
4. sapi 和各种服务器的接口调用,例如apache、IIS等,也包含一般的fastcgi、cgi等。
5. win32 和 Windows 下编译 PHP 有关的脚本。
6. Zend 文件夹核心的引擎,所有的 Zend API 定义与宏等。
7. scripts Linux 下的脚本目录。
8. tests 测试脚本目录
9. sapi 各类 Web 服务器的接口。
10.TSRM Zend 和 PHP 的 “线程安全资源管理器” (TSRM) 目录。
11.pear 这个目录就是“PHP 扩展与应用仓库”的目录。包含了PEAR 的核心文件。
其中几个重要的文件绝对值得你共时间去了解:
php-src/main/php.h, 位于PHP 主目录。这个文件包含了绝大部分 PHP 宏及 API 定义。
php-src/Zend/zend.h, 位于 Zend 主目录。这个文件包含了绝大部分 Zend 宏及 API定义。
php-src/Zend/zend_API.h, 也位于 Zend 主目录,包含了Zend API的定义
乐意黎
2018-11-30
本文地址: https://blog.csdn.net/aerchi/article/details/84646179