如何在Mac OS X Catalina中的PHP上加载memcached? [英] How to load memcached on PHP in Mac OS X Catalina?
问题描述
在过去的3个小时里,我几乎尝试了一切.我只是似乎没有在PHP上加载它.我能够通过brew install memcached
安装它,并通过memcached -d
成功使它作为后台服务运行.但这并不是我真正想要的.
I have tried virtually everything I could for the last 3 hours. I just don't seem to get it to load on PHP. I was able to install it via brew install memcached
and successfully make run it as a background service via memcached -d
. But that's not really what I am looking for.
我正在考虑将其作为我的PHP模块之一进行加载.在终端上运行php -m
根本不会在其上列出memcached
.在运行时查看phpinfo()
或print_r(get_loaded_extensions());
都没有给我带来任何运气.我试图通过extension_loaded('memcached')
之类的东西在我的项目中正式访问它,当然,这会返回一个伪造的atm值.
I am looking at loading it as one of my PHP modules. Running php -m
on the terminal does not list memcached
on it at all. Neither looking at phpinfo()
or print_r(get_loaded_extensions());
on runtime gave me any luck. I am trying to officially access it in my project via something like extension_loaded('memcached')
, of course, this returns a falsy value atm.
我尝试了以下解决方案:
I have tried solutions like below:
如何安装memcached模块在MacOS High Sierra上安装php@7.1?
https://donatstudios.com/OS-X-Mavericks -Memcached-PHP-Extension-Installation
大多数解决方案与以上链接相似.不幸的是,由于类似于以下的问题,这对我不起作用:
Most of the solutions are similar to the above linked. Unfortunately, this isn't working for me because of an issue similar to this:
在执行make
命令时,我也会遇到以下错误:
I also get below error when executing a make
command:
make:***未指定目标,也未找到任何makefile.停止.
make: *** No targets specified and no makefile found. Stop.
以及运行./configure
正在检查会话包括...配置:错误:找不到 php_session.h
checking for session includes... configure: error: Cannot find php_session.h
同时,由于以下错误,我也无法通过pecl install memcached
尝试安装:
Meanwhile, I also cannot attempt an install via pecl install memcached
due to the error below:
配置下载目录"/tmp/pear/install"不可写. 将download_dir配置变量更改为可写目录以避免这种情况 警告
configuration download directory "/tmp/pear/install" is not writeable. Change download_dir config variable to a writeable dir to avoid this warning
基本上所有内容都不起作用.老实说,我什至不知道如何开始写这个问题,所以我只是把所有东西都扔在这里.
Basically everything just doesn't work. And honestly, I didn't even know how to start writing this question, so I'm just kinda throwing everything in here.
自从Catalina以来,没有关于在PHP上安装memcached的最新讨论无济于事.许多资源只有5年的历史,这并不是一个好兆头,其中许多甚至不再是有效的解决方案.
It doesn't help that there are no recent discussions about installing memcached on PHP since Catalina. A lot of resources are just 5 years old and that's not a good sign, a number of them aren't even valid solutions anymore.
我迷失了方向.为什么这个东西配置如此复杂,这超出了我的理解.如果有人可以将我指向正确的方向,那就太好了!
I am losing my mind. Why this thing is so complicated to configure is beyond my comprehension. If someone can point me in the right direction that would be great!
推荐答案
所以我能够在2个工作日后找到解决方案.您应该做的就是摆脱使用macOS中内置的Apache/PHP,而使用Homebrew中的内置Apache/PHP.
So I was able to find a solution after 2 working days. What you should do is move away from using built-in Apache/PHP from macOS and use the ones from Homebrew.
这是我执行的描述性分步程序:
Here are the descriptive step-by-step procedure I did:
1)卸载内置的Apache.
1) Unload the built-in Apache.
2)通过brew install httpd
从Homebrew安装新的Apache,然后运行服务
2) Install a new Apache from Homebrew via brew install httpd
and then run the service
3)通过brew install php
4)从/usr/local/etc/httpd/
配置httpd.conf,包括加载Homebrew PHP模块,mod_rewrite,设置DirectoryIndex,ServerName,默认侦听端口等.
4) Configure httpd.conf from /usr/local/etc/httpd/
, including loading Homebrew PHP module, mod_rewrite, setting up DirectoryIndex, ServerName, default Listen port, etc.
4.1)如果您使用的是虚拟主机,请在/usr/local/etc/httpd/extra/
4.1) If you are using virtual hosts, set this up on /usr/local/etc/httpd/extra/
5)配置〜/.bash_profile以使用新的PHP版本(通过php -v
或which php
测试)
5) Configure ~/.bash_profile to use the new PHP version (test via php -v
or which php
)
6)安装PEAR
7)通过PEAR安装memcached
7) Install memcached via PEAR
我已经列出了可以使用的链接列表:
I have compiled a list of links that you can use:
Apache& PHP安装
https://tecadmin.net/install-apache-macos-homebrew/
https://getgrav.org/blog/macos-catalina -apache-multiple-php-versions
https://gist.github.com/DragonBe/0faebe58deced34744953e3bf6afbec7
按照brew info php
将Homebrew PHP配置为Homebrew Apache
Follow brew info php
to configure Homebrew PHP to Homebrew Apache
配置bash配置文件以默认使用自制php
PHP --version在osX上显示不正确 如何使用brew安装的php?
安装PEAR并进行配置
https://jasonmccreary.me/articles/install-pear-pecl-mac
通过PEAR安装内存缓存
pecl install memcached
然后按照说明进行操作
pecl install memcached
then follow instructions
或
如何安装memcached模块在MacOS High Sierra上安装php@7.1?
https://donatstudios.com/OS-X-Mavericks -Memcached-PHP-Extension-Installation
这篇关于如何在Mac OS X Catalina中的PHP上加载memcached?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!