- Installing the PHP «memcached» Extension
- Please Note
- Comment by: liangyu on Oct. 30, 2013
- Comment by: liangyu on Oct. 30, 2013
- Comment by: marvin on Oct. 31, 2013
- Comment by: jv on Nov. 2, 2013
- Comment by: jv on Nov. 2, 2013
- Comment by: Jared on Nov. 8, 2013
- Comment by: Jared on Nov. 8, 2013
- Comment by: will on Feb. 12, 2014
- Comment by: Colin on Feb. 24, 2014
- Comment by: Sid on Mar. 5, 2014
- Comment by: Valentin on Mar. 20, 2014
- Comment by: follower on Aug. 31, 2014
- Comment by: Jesse G. Donat on Sep. 2, 2014
- Comment by: follower on Sep. 2, 2014
- Comment by: JB Manos on Oct. 18, 2014
- Comment by: Rob Colburn on Nov. 11, 2014
- Comment by: Jesse G. Donat on Nov. 11, 2014
- Comment by: MintyStark on Nov. 17, 2014
- Comment by: Martin on Mar. 6, 2015
- Comment by: prabhat on Oct. 2, 2015
- Comment by: Jesse G. Donat on Oct. 2, 2015
- Comment by: prabhat on Oct. 2, 2015
- Comment by: Ansuraj on Jan. 27, 2016
- Comment by: Jesse G. Donat on Feb. 1, 2016
- Comment by: olidev on May. 11, 2017
- Comment by: Charlotte on Aug. 24, 2017
- Comment by: Andi on Sep. 20, 2017
- tomysmile / memcached_macosx.md
- Niteshvgupta / readme.md
- This comment has been minimized.
- shrestharoshan commented Feb 24, 2017
- This comment has been minimized.
- kowap commented Mar 23, 2017
- This comment has been minimized.
- Oliboy50 commented May 16, 2017
- This comment has been minimized.
- f4eyq commented Jun 15, 2017 •
- This comment has been minimized.
- healdev commented Jan 19, 2018
- This comment has been minimized.
- david-blanchard commented Jan 31, 2018
- This comment has been minimized.
- markhughes commented Mar 21, 2018
- This comment has been minimized.
- derkjn commented Apr 5, 2018
- This comment has been minimized.
- vdroznik commented Apr 9, 2018
- This comment has been minimized.
- lexthor commented Jan 22, 2019
- This comment has been minimized.
- Manyaka commented Aug 12, 2019 •
- This comment has been minimized.
- Jekins commented Jan 13, 2020
- This comment has been minimized.
- muhaimincs commented Jan 31, 2020
- This comment has been minimized.
- travisdetert commented Apr 7, 2020
- This comment has been minimized.
- adampatterson commented Feb 16, 2021 •
Installing the PHP «memcached» Extension
Please Note
This tutorial only covers the default PHP installation that ships with Mac OS X / macOS. If you have installed a new installation this does not cover you.
For those using brew, you can simply brew install the appropriate brew formula for the extension.
These directions are verified to work with Mac OS X 10.9 Mavericks through macOS 10.14 Mojave.
System Integrity Protection
If you are running OS X El Capitan or newer you will need to disable System Integrity Protection to modify system files and directories.
To disable System Integrity Protection, boot into recovery mode by restarting and then holding ⌘R as you hear the startup chime. Then start the Terminal from the Utilities menu.
Run the following command
Then reboot. You are good to go.
If you wish to turn it back on, follow the instructions above but instead use:
Click here for a full post on the topic.
The first step is to install the latest version of Xcode. On modern versions of MacOS this can be done from the App Store.
After this, install the Xcode developer tools.
Special note to Mojave users if the following steps fail, you may need to reinstall your Xcode header files. Instructions for that can be found here.
Next we will need to install the required dependencies before we can build the extension. If you are not already using Homebrew you should be.
You will also want to make sure you have PEAR installed; full instructions can be found here but can be summarized as follows:
Then in the /tmp directory we will create a folder we can work in.
Next we will use pecl, part of pear, to fetch the current version of the extension.
The version of the memcached extension will vary so you will need to update the paths accordingly.
Finally you will need to add the following line to your php.ini
You can verify your installation with the following:
Depending on your setup now you may want to restart apache.
You should be all set to go!
Comment by: liangyu on Oct. 30, 2013
as to the command —phpize, users may meet this problem like «Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.»
— brew install autoconf
can fix this problem
Comment by: liangyu on Oct. 30, 2013
The terminal will complain it cannot find the path for libmemcached lib.
Didn’t you meet this error?
Comment by: marvin on Oct. 31, 2013
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [memcached.la] Error 1
I am getting this error on ‘make’
Comment by: jv on Nov. 2, 2013
brew install autoconf
brew install Libmemcached
then phpize etc.
Comment by: jv on Nov. 2, 2013
@marvin, edit php_libmemcached_compat.h
add the following line at the end:
typedef const struct memcached_server_st *memcached_server_instance_st;
Comment by: Jared on Nov. 8, 2013
Thanks for the guide. I followed your guide and was successful on building memcahce on my localhost. However when I try to connect to a remote memcache server it crashes with the following error. any ideas?
donedyld: lazy symbol binding failed: Symbol not found: _mmc_queue_free
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20100525/memcache.so
Expected in: flat namespace
dyld: Symbol not found: _mmc_queue_free
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20100525/memcache.so
Expected in: flat namespace
Comment by: Jared on Nov. 8, 2013
Comment by: will on Feb. 12, 2014
Comment by: Colin on Feb. 24, 2014
Comment by: Sid on Mar. 5, 2014
Comment by: Valentin on Mar. 20, 2014
in a nutshell run in console:
xcode-select —install
brew install autoconf
brew install Libmemcached
cd /tmp
mkdir memcached-work
cd memcached-work
pecl download memcached
open memcached-2.1.0.tgz
cd memcached-2.1.0/memcached-2.1.0
phpize
./configure
make
sudo make install
Then add extension = memcached.so to php.ini.
to find which php.ini you’re using run in console:
php —ini
Don’t forget to restart apache:
sudo apachectl -k restart
Comment by: follower on Aug. 31, 2014
Hi
I’ve done all this steps, restarted Apache.
php —ini says ‘memcached support => enabled’, etc. (too many lines).
But I still get error «Fatal error: Class ‘Memcached’ not found in . »
What should I check?
Comment by: Jesse G. Donat on Sep. 2, 2014
Comment by: follower on Sep. 2, 2014
Yes, Apache uses another copy of PHP,
Of course I tried rebooting.
How can I check if nothing disabling it?
PHP config has included memcached extension (‘/etc/php.ini’ path is displaying in phpinfo() output)
Comment by: JB Manos on Oct. 18, 2014
There is a built-in PEAR installation on the mac. It’s there, but goes more smoothly if you install Xcode command line tools.
then, run the PEAR installer on the built-in: sudo php -d detect_unicode=0 /usr/lib/php/install-pear-nozlib.phar
upgrade PEAR: sudo pear upgrade
then PECL: sudo pecl install -f . (in this case, memcached)
The benefit to using this method is that you’ll get a system-wide pear installation for the native PHP. Cheers!
Comment by: Rob Colburn on Nov. 11, 2014
Brew now has a PHP memcached Extension
brew install php55-memcached
(replace with your version of brew php formulae)
Comment by: Jesse G. Donat on Nov. 11, 2014
Comment by: MintyStark on Nov. 17, 2014
Thanks for the Post.
I think I got it 99% of the way there.
I installed it with my AMPPS PHP
/Applications/AMPPS/php-5.3/bin/phpize CFLAGS=’-arch i386′
CFLAGS=’-arch i386′ ./configure —with-php-config=/Applications/AMPPS/php-5.3/bin/php-config
make
sudo make install
Everything installed ok.
PHP is showing class_exists(‘Memcached’) as true, but Memcached is not displayed in phpinfo(). Also I get a crash when connecting to it.
Also my apache error log shows:
dyld: Symbol not found: _memcached_create
Referenced from: /Applications/AMPPS/php-5.3/lib/extensions/ext/memcached.so
Expected in: flat namespace
[Mon Nov 17 13:50:18.953115 2014] [core:notice] [pid 53238] AH00052: child pid 56107 exit signal Trace/BPT trap (5)
Comment by: Martin on Mar. 6, 2015
Thanks for these instructions. When i run the xcode-select —install command i get the following error:-
xcode-select: error: no developer tools were found, and no install could be requested (perhaps no UI is present), please install manually from ‘developer.apple.com’.
I however installed from the AppStore — is that ok?
Comment by: prabhat on Oct. 2, 2015
How to install it for PHP CLI?
Comment by: Jesse G. Donat on Oct. 2, 2015
Comment by: prabhat on Oct. 2, 2015
Comment by: Ansuraj on Jan. 27, 2016
Even after following the above steps, I was unable to use memcached in my project, neither was I able to see it in phpinfo(). It was because memcached and php5-memcached extension was installed via cli.
I had to do the following:
sudo cp /usr/local/Cellar/php55/5.5.30/lib/php/extensions/no-debug-non-zts-20121212/memcache.so /usr/lib/php/extensions/no-debug-non-zts-20121212/memcache.so
sudo cp /usr/local/Cellar/php55/5.5.30/lib/php/extensions/no-debug-non-zts-20121212/memcached.so /usr/lib/php/extensions/no-debug-non-zts-20121212/memcached.so
Please change the above commands to suit your php-version paths.
Comment by: Jesse G. Donat on Feb. 1, 2016
This is because you are using an instance of PHP installed with Brew and not the base MacOS X version. My instructions only cover the base php installation.
You should actually not be following these directions and instead just install the extension with brew.
Comment by: olidev on May. 11, 2017
Comment by: Charlotte on Aug. 24, 2017
Hi! I was almost done with all steps but I got stuck when I encountered an error on make.
I got this error:
./php_memcached.h:23:10: fatal error: ‘Zend/zend_smart_str.h’ file not found
Any idea on how to fix this? Thanks!
Comment by: Andi on Sep. 20, 2017
- More Info Site MapContactFeed:ATOM / JSON
- Jesse G. Donat “It is one thing to insult a man on his character, but to insult a man on his grade of rice, that’s another thing entirely.”
- Other Sites GitHub / KeybaseBoomerang!Oasisband.net
Jesse G. Donat is a Minneapolis based Software Developer who loves all things simple.
Lover of Liberty 🗽 Defender of Nonviolence ☮️
Источник
tomysmile / memcached_macosx.md
Installing memcached on Mac with Homebrew and Lunchy
This is a quick guide for installing memcached on a Mac with Homebrew, and starting and stopping it with Lunchy. I hope this tutorial will get your memcached up and running in no time.
Step 1 — Install Homebrew
Installing Homebrew is super easy. Just paste this in your terminal —
You should also make sure your Homebrew is up-to-date. Use update and doctor commands to update and fix any issues it may have.
Step 2 — Install memcached
Installing anything with Homebrew is a breeze. All you need is
When you installed memcached, it put a file named homebrew.mxcl.memcached.plist in /usr/local/Cellar/memcached/$version/; you copy that file into
/Library/LaunchAgents and then tell launchd to start it with launchctl load -w
If you were watching the console carefully during the brew install command, it should have said something about doing these exact steps. If you run brew info it’ll re-print this information, e.g. brew info memcached.
Step 3 — Install Lunchy
But why remember this long location to start memcached every time? Lunchy is a gem that simplifies the command line interface to launchctl. To install Lunchy, do
Step 4 — Start/Stop memcached
Now we configure lunchy to start/stop memcached using simple lunchy commands.
Lines 1 and 2 copy the plist file to LaunchAgents. The lines 3 and 4 start and stop memcached. Since lunchy takes care of the long commands we talked about in Step 2, we don’t have to use the launchctl command to launch anymore.
Verify the Installation
Verify that you have successfully installed Memcached.
Using the Memcached Telnet Interface You can connect to the Memcached server with Telnet.
To test if everything is working correctly, set a cache item.
To retrieve the cache item.
To exit the Telnet session.
For more information on using Memcached Telnet commands.
Invalidate All Cache Items
To flush the contents of your Memcached server. Useful in a development environment.
Источник
Niteshvgupta / readme.md
1. Install PHP7 with brew
brew install php70
2. Install Memcache from source on PHP7 branch
3. Add the Memcache extension to the php.ini for PHP7
Add extension=memcache.so under the extensions section.
This comment has been minimized.
Copy link Quote reply
shrestharoshan commented Feb 24, 2017
getting PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/Cellar/php70/7.0.14_7/lib/php/extensions/no-debug-non-zts-20151012/memcache.so’ — dlopen(/usr/local/Cellar/php70/7.0.14_7/lib/php/extensions/no-debug-non-zts-20151012/memcache.so, 9): image not found in Unknown on line 0
This comment has been minimized.
Copy link Quote reply
kowap commented Mar 23, 2017
I have a problem. (Mac OS)
`➜ pecl-memcache git:(NON_BLOCKING_IO_php7) git clone -b NON_BLOCKING_IO_php7 https://github.com/websupport-sk/pecl-memcache.git
Cloning into ‘pecl-memcache’.
remote: Counting objects: 1879, done.
remote: Total 1879 (delta 0), reused 0 (delta 0), pack-reused 1879
Receiving objects: 100% (1879/1879), 445.79 KiB | 523.00 KiB/s, done.
Resolving deltas: 100% (1308/1308), done.
➜ pecl-memcache git:(NON_BLOCKING_IO_php7) ✗ cd pecl-memcache
➜ pecl-memcache git:(NON_BLOCKING_IO_php7) phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
➜ pecl-memcache git:(NON_BLOCKING_IO_php7) ./configure
zsh: no such file or directory: ./configure
➜ pecl-memcache git:(NON_BLOCKING_IO_php7) make && make install
make: *** No targets specified and no makefile found. Stop.`
This comment has been minimized.
Copy link Quote reply
Oliboy50 commented May 16, 2017
it works for php7.1 too, thanks 👍
This comment has been minimized.
Copy link Quote reply
f4eyq commented Jun 15, 2017 •
Tnx for your work, i’ve installed it here :
=> debian 8.8, PHP : 7.0.20-1
This comment has been minimized.
Copy link Quote reply
healdev commented Jan 19, 2018
Hey guys, anyone tried to install this with OS X High Sierra?
Getting the following in command «phpize«:
grep: /usr/include/php/main/php.h: No such file or directory grep: /usr/include/php/Zend/zend_modules.h: No such file or directory grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory Configuring for: PHP Api Version: Zend Module Api No: Zend Extension Api No:
Then getting this on command «./configure«:
checking for grep that handles long lines and -e. /usr/bin/grep checking for egrep. /usr/bin/grep -E checking for a sed that does not truncate output. /usr/bin/sed checking for cc. cc checking whether the C compiler works. yes checking for C compiler default output file name. a.out checking for suffix of executables. checking whether we are cross compiling. no checking for suffix of object files. o checking whether we are using the GNU C compiler. yes checking whether cc accepts -g. yes checking for cc option to accept ISO C89. none needed checking how to run the C preprocessor. cc -E checking for icc. no checking for suncc. no checking whether cc understands -c and -o together. yes checking for system library directory. lib checking if compiler supports -R. no checking if compiler supports -Wl,-rpath. yes checking build system type. x86_64-apple-darwin17.3.0 checking host system type. x86_64-apple-darwin17.3.0 checking target system type. x86_64-apple-darwin17.3.0 checking for PHP prefix. /usr checking for PHP includes. -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib checking for PHP extension directory. /usr/lib/php/extensions/no-debug-non-zts-20160303 checking for PHP installed headers prefix. /usr/include/php checking if debug is enabled. no checking if zts is enabled. no checking for re2c. no configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. checking for gawk. no checking for nawk. no checking for awk. awk checking if awk is broken. no checking whether to enable memcache support. yes, shared checking whether to enable memcache session handler support. yes checking for the location of ZLIB. no checking for the location of zlib. configure: error: memcache support requires ZLIB. Use —with-zlib-dir= to specify prefix where ZLIB include and library are located
And of course «make && make install» not working.
make: *** No targets specified and no makefile found. Stop.
This comment has been minimized.
Copy link Quote reply
david-blanchard commented Jan 31, 2018
You should try the homebrew php installation, then install the memcached extension
for me it was :
brew install php72-memcached
nothing more to do.
I hope it helps
This comment has been minimized.
Copy link Quote reply
markhughes commented Mar 21, 2018
@david-blanchard memcached and memcache are different
This comment has been minimized.
Copy link Quote reply
derkjn commented Apr 5, 2018
This doesn’t seem to work on php7.2, plus now brew has removed/changed the way php is distributed. Additional modules now should be pulled via pecl, which in my case doesn’t work at all. I’m pretty stuck 😄
This comment has been minimized.
Copy link Quote reply
vdroznik commented Apr 9, 2018
Works with new brew distribution scheme. Tested with php@7.0
This comment has been minimized.
Copy link Quote reply
lexthor commented Jan 22, 2019
thank you! it worked on php 7.1
This comment has been minimized.
Copy link Quote reply
Manyaka commented Aug 12, 2019 •
php 7.3.7
make: *** No targets specified and no makefile found. Stop.
This comment has been minimized.
Copy link Quote reply
Jekins commented Jan 13, 2020
php 7.2
make: *** No targets specified and no makefile found. Stop.
Help plz
This comment has been minimized.
Copy link Quote reply
muhaimincs commented Jan 31, 2020
is there any solid steps for PHP 7.3
This comment has been minimized.
Copy link Quote reply
travisdetert commented Apr 7, 2020
Why does installing this seem to break with every single php release on MacOS? I’ve had to update this nearly every time.
This comment has been minimized.
Copy link Quote reply
adampatterson commented Feb 16, 2021 •
I am on macOS 11.1
If you get the following after running phpize :
Then run brew install autoconf from this Stack Overflow post
I then got an error:
So I ran brew install zlib which at first did not fix the error.
I ran the command with the zlib path ./configure —with-zlib-dir=/usr/local/opt/zlib
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник