简体   繁体   English

如何在 MacOS High Sierra 上为 php@7.1 安装 memcached 模块?

[英]How to install memcached module for php@7.1 on MacOS High Sierra?

I have the issue installing a memcached's module for php 7.1.我在为 php 7.1 安装 memcached 模块时遇到问题。 I use MacOS High Sierra and php@7.1 installing using homebrew.我使用 MacOS High Sierra 和 php@7.1 使用自制软件安装。 During the installation of memcached module for php using command在使用命令为 php 安装 memcached 模块期间

pecl install memcached pecl 安装 memcached

I received the errors:我收到错误:

checking for zlib location... configure: error: memcached support requires ZLIB.检查 zlib 位置...配置:错误:memcached 支持需要 ZLIB。 Use --with-zlib-dir= to specify the prefix where ZLIB headers and library are located ERROR: `/private/tmp/pear/install/memcached/configure --with-php-config=/usr/local/opt/php@7.1/bin/php-config --with-libmemcached-dir' failed使用 --with-zlib-dir= 指定 ZLIB 头文件和库所在的前缀错误:`/private/tmp/pear/install/memcached/configure --with-php-config=/usr/local/opt/ php@7.1/bin/php-config --with-libmemcached-dir' 失败

But I have installed zlib.但是我已经安装了 zlib。 I can't find a way how to install memcached module after the changes in homebrew repository.在自制软件存储库中发生更改后,我找不到如何安装 memcached 模块的方法。

  1. pecl bundle memcached
  2. Change to the directory it output切换到它输出的目录
  3. phpize
  4. Make sure libmemcached and zlib are installed ( brew install libmemcached zlib )确保安装了 libmemcached 和 zlib( brew install libmemcached zlib
  5. Get the zlib directory ( brew list zlib )获取 zlib 目录( brew list zlib
  6. ./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/ (replace the zlib path with the one from the previous command) ./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/ (用上一个命令中的路径替换zlib路径)
  7. make
  8. make install
  9. Add the extension line in your php.ini file (ex. change the paths to match what make install output. I added this to my /usr/local/etc/php/7.4/conf.d directory in a file called ext-memcached.ini在 php.ini 文件中添加扩展行(例如,更改路径以匹配 make install 输出的内容。我将此添加到我的/usr/local/etc/php/7.4/conf.d目录中名为 ext-memcached 的文件中.ini

[memcached] extension=memcached.so

  1. Verify you installed the module php -m should show you memcached in the outputted list验证您安装了模块php -m应该在输出列表中显示 memcached

You can use env variable PHP_ZLIB_DIR to tell it where zlib is.您可以使用环境变量PHP_ZLIB_DIR来告诉它 zlib 在哪里。

PHP_ZLIB_DIR=/usr/local/opt/zlib pecl install memcached

Full installation.完整安装。

brew install zlib
yes no | PHP_ZLIB_DIR=$(brew --prefix zlib) pecl install memcached

To install memcached prerequisite安装 memcached 先决条件

  • Install pkg-config and zlib using brew install pkg-config zlib使用brew install pkg-config zlib
  • Check Php Version for which you installing should be linked.检查您安装的 PHP 版本应该被链接。 php -v tells you which php version is active for cli. php -v告诉您哪个 php 版本对于 cli 处于活动状态。
  • pecl config-get ext_dir will tell you which version configuration files are set. pecl config-get ext_dir会告诉你设置了哪个版本的配置文件。
  • Get configuration path for zlib that is required while installing brew list zlib Install using sudo pecl install memcached While installing it will ask zlib directory [no] : in that paste zlib configuration path /opt/homebrew/Cellar/zlib/1.2.11 example zlib directory [no] : /opt/homebrew/Cellar/zlib/1.2.11获取安装brew list zlib所需的 zlib 配置路径 使用sudo pecl install memcached安装 安装时会询问zlib directory [no] :在该粘贴 zlib 配置路径/opt/homebrew/Cellar/zlib/1.2.11示例zlib directory [no] : /opt/homebrew/Cellar/zlib/1.2.11

Restart your php and nginx/apache2 brew services restart php@7.2 brew services restart nginx brew services restart apache2重启你的 php 和 nginx/apache2 brew services restart php@7.2 brew services restart nginx brew services restart apache2

You can check extension is installed or not by using php -m .您可以使用php -m来检查扩展是否安装。

Note : Am using MacPro M1 silicon chip notebook.注意:我使用的是MacPro M1 silicon chip笔记本。 Installed using homebrew .使用homebrew安装。 struggle a lot to fix this issue.努力解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM