使用phpize编译安装phpredis扩展(PECL 扩展库)
- 服务器运维
- 2022-04-26 01:13:26
- 124
有时候不能用 pecl 命令安装想要的扩展,此时可以使用官方提供的 phpize 扩展库编译环境,此文就是演示用 phpize 安装 redis 扩展。
$ cd extname$ phpize$ ./configure$ make# make install
编译安装按顺序使用的命令如上所示,现在开始(我的系统 MacOS)
一、从github拉取phpredis扩展源代码
git clone https://github.com/phpredis/phpredisgit checkout -b release/5.3.5 # 切换到发布版本分支(可选)cd phpredis
二、通过phpize适配phpredis扩展
注:可用 phpize --help 取得执行命令的绝对路径
sudo /usr/local/opt/php@7.2/bin/phpize
成功输出内容,大概如下:
... ...Configuring for:PHP Api Version: 20170718Zend Module Api No: 20170718Zend Extension Api No: 320170718
三、编译前指定php配置获取路径(官方php-config解释)
./configure --with-php-config=/usr/local/Cellar/php@7.2/7.2.29/bin/php-config
成功输出内容,大概如下:
... ... creating libtool appending configuration tag "CXX" to libtoolconfigure: creating ./config.statusconfig.status: creating config.h
四、配置准备就绪,开始编译安装
make && make install
成功输出内容,大概如下:
... ...----------------------------------------------------------------------Libraries have been installed in: /Users/andy/code/project/free-andy/phpredis/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, andspecify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable during execution 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/Cellar/php@7.2/7.2.29/pecl/20170718/
五、修改 php.ini 文件配置
注:php --ini 可以找到配置文件路径
vim /usr/local/etc/php/7.2/php.ini
在 Dynamic Extensions 配置组下,添加一行 extension=redis.so
最后重启 php 和 php-fpm ,使用 php -m 看到 redis 就说明安装成功了。
(完)
作者:一条大河
声明:内容整理自网络,文章版权归原作者所有,旨在分享有价值的内容,文章如有侵权请联系本站删除,部分文章如未署名作者来源请联系我们及时备注,感谢您的支持。
本文链接:https://www.shunshiseo.com/yunwei/41.html
发表评论