有時(shí)候無法通過 PECL 命令安裝所需的擴(kuò)展,這時(shí)可以利用官方提供的 phpize 工具編譯環(huán)境,以下是演示如何使用 phpize 安裝 redis 擴(kuò)展的詳細(xì)步驟。
$ cd extname $ phpize $ ./configure $ make # make install
編譯安裝所需的命令如上所示,以下是在我的 MacOS 系統(tǒng)上的操作步驟:
步驟一:從 GitHub 上獲取 phpredis 擴(kuò)展的源代碼
git clone https://github.com/phpredis/phpredis git checkout -b release/5.3.5 # 切換到發(fā)布版本分支(可選) cd phpredis
步驟二:使用 phpize 適配 phpredis 擴(kuò)展
注意:可以通過 `phpize --help` 獲取執(zhí)行命令的絕對(duì)路徑
sudo /usr/local/opt/php@7.2/bin/phpize
成功輸出內(nèi)容大致如下:
... ... Configuring for: PHP Api Version: 20170718 Zend Module Api No: 20170718 Zend Extension Api No: 320170718
步驟三:在編譯之前指定 php 配置獲取路徑(官方 php-config 解釋)
./configure --with-php-config=/usr/local/Cellar/php@7.2/7.2.29/bin/php-config
成功輸出內(nèi)容大致如下:
... ... creating libtool appending configuration tag "CXX" to libtool configure: creating ./config.status config.status: creating config.h
步驟四:配置準(zhǔn)備就緒,開始編譯安裝
make && make install
成功輸出內(nèi)容大致如下:
... ... ---------------------------------------------------------------------- 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, and specify 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`
最后:重啟
最后,重新啟動(dòng) php 和 php-fpm,使用 `php -m` 命令查看是否出現(xiàn) redis,以確認(rèn)安裝成功。文章來源:http://www.zghlxwxcb.cn/article/741.html
通過以上步驟,您可以順利使用 phpize 工具編譯安裝 phpredis 擴(kuò)展,確保您的 PHP 環(huán)境中成功集成了 redis 擴(kuò)展。文章來源地址http://www.zghlxwxcb.cn/article/741.html
到此這篇關(guān)于使用 phpize 編譯安裝 phpredis PECL擴(kuò)展詳細(xì)步驟及注意事項(xiàng)的文章就介紹到這了,更多相關(guān)內(nèi)容可以在右上角搜索或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!