I'm having trouble installing the "memcached" PHP extension from PECL, though I can successfully installed the "memcache" extension. (They are separate PHP extensions.)
For example, these commands work okay:
$ sudo pecl install memcache
$ sudo pecl install APC
$ sudo pecl install oauth
However, attempting to install memcached causes errors:
$ sudo pecl install memcached
...
ld: library not found for -lmemcached
collect2: ld returned 1 exit status
make: *** [memcached.la] Error 1
ERROR: `make' failed
I'm using pecl, memcached, and libmemcached from Mac Ports (macports.org) on a recent Intel Mac. The libmemcached libraries can be found in /opt/local:
/opt/local/include/libmemcached
/opt/local/include/libmemcached/libmemcached_config.h
/opt/local/lib/libmemcached.2.0.0.dylib
/opt/local/lib/libmemcached.2.dylib
/opt/local/lib/libmemcached.a
/opt/local/lib/libmemcached.dylib
/opt/local/lib/libmemcached.la
Any idea what I may be doing wrong?
Andrei Zmievski (developer of the memcached plugin) kindly answered my email request with the following instructions:
$ pecl download memcached
$ tar zxvf memcached-1.0.0.tgz (or whatever version downloads)
$ cd memcached-1.0.0
$ phpize
$ ./configure --with-libmemcached-dir=/opt/local
$ make
$ sudo make install
This worked perfectly.
same situation here. i had to do the above, but with explicit path names (i run my php etc. out of /opt/local)
/opt/local/bin/pecl download memcached
tar zxvf memcached-1.0.0.tgz
cd memcached-1.0.0
/opt/local/bin/phpize
./configure --prefix=/opt/local --with-php-config=/opt/local/bin/php-config --with-libmemcached-dir=/opt/local
make
make install
normally this kind of stuff is pretty simple on os x with macports, but there is no php5-memcached package yet (only one for the older, memcache (no "d") package). oh, an i also had to install an older version of libmemcached, since the latest version didn't compile on os x 10.5.8 for me. oy!
As you've seen, the new memcached extension, uses libmemcached to do the heavy lifting. If it were Linux, I'd say that it was possible that you don't have /opt/local/lib/ listed in ld.so.conf (and run 'ldconfig').
MaxOSX doesn't use that though. It is, however installable from 'ports' apparently. http://lsimons.wordpress.com/2008/05/01/serious-php-part-1/
Well, after many tries only this solution works for me.
Install XAMPP
Install brew (https://github.com/Homebrew/homebrew/wiki/Installation)
$ brew
install libmemcached
cd /Applications/XAMPP/xamppfiles/bin/
$ sudo ./pecl install memcached
Build process completed successfully Installing
'/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/memcached.so'
install ok: channel://pecl.php.net/memcached-2.2.0 configuration
option "php_ini" is not set to php.ini location You should add
"extension=memcached.so" to php.ini
VOILA !!
Related
Lately, I have been trying to install the pecl memcache PHP extension on OSX Catalina with brew memcached installed and I'm getting the following error every time I try the install process:
configure: error: memcache support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
I have tried with pecl install memcache and with pecl install --configureoptions='with-zlib-dir="path"' memcache to no avail. It always gets the same point and it fails.
From what I have reviewed on different topics regarding the installation of the package the issue seems to be with the -D option in the pecl install command, because when I do a manual install from the source code passing the argument --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11 to the ./configure command it works like a charm and installs the package but is now not listed in pecl list installed packages and as so it cannot be uninstalled.
The issue is I need pecl to manage the installation of the package to be able to uninstall it any time when the environment changes from project to protect.
A quick fix for this (found via https://bugs.php.net/bug.php?id=56522) is to use the PHP_ZLIB_DIR variable instead of --with-zlib-dir.
i.e. PHP_ZLIB_DIR=/usr/local/Cellar/zlib/1.2.11 pecl install memcache
I've struggled with the -D option before as well - near as I can tell it's completely broken.
Can anyone help me install php-redis in MAC OSX .
brew install php-redis
not working.
pecl install php-redis
also not working getting -
invalid package name/package file "php-redis".
Homebrew Error:
homebrew_error
git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install
Add extension=redis.so in your php.ini
brew services restart php#7.2
make test
You can check working or not
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
As of 2019, with homebrew php7.2 and up, pecl is now installed by default alongside the php binaries.
To see this for yourself type which pecl.
Steps to install
Check your version of redis, then find a suitable version of the extension here.
If unfamiliar with pecl, type pecl to see the options.
Issue pecl install redis-5.0.2. (or your version). Enter no to each question asked if you're not sure.
If that succeeds check the new file it created at: /usr/local/lib/php/pecl/20180731/redis.so
The install will have added extension="redis.so" to top of your php ini.
Check that by opening the file /usr/local/etc/php/7.3/php.ini.
(assuming you're on 7.3 there)
brew services restart php.
php -i | grep Redis
Redis Support => enabled
Redis Version => 5.0.2
This is what I just did in September 2019 and it works for me.
If what mwal wrote above doesn't work (please try his/her answer first),
first, try to uninstall first (if you have it but broken):
sudo pecl uninstall redis
and after that run:
sudo pecl install redis
After that, ini the php.ini, use full path for the extension.
Mine was /usr/local/Cellar/php#7.3/7.3.21/pecl/20180731/redis.so (assuming you are using php#7.3)
so at the top of my php.ini file is like this:
extension="/usr/local/Cellar/php#7.3/7.3.21/pecl/20180731/redis.so"
Here are steps to use pickle, for PHP >= 7.3 (tested with 8.1):
brew install pickle
pickle install redis
Find your php.ini location via php -i|grep php.ini
Edit the php.ini, insert extension=redis. Preferable at Dynamic Extensions section.
No restart of Apache httpd service is required. You may test your PHP code with Redis
Bonus
If you use VS Code, to enable intellisense / auto complete, at Preference -> paste intelephense.stubs at Search setting box -> Add Item -> select redis.
If you got the following error,
Please make sure the PHP Redis extension is installed and enabled
despite doing everything in the verified answer above, try valet restart . It worked for me
I have tried all these solutions but didn't work for me for a while so I tried this link https://developer.redis.com/develop/php/ from the original docs and it works as charm
If someone gets an error during sudo pecl install redis
Warning: mkdir(): File exists in System.php on line 294
PHP Warning: mkdir(): File exists in /opt/homebrew/Cellar/-----/pear/System.php on line 294
that means you need to create the broken directory manually.
Try to create the directory...
pecl config-get ext_dir | pbcopy
mkdir -p {paste clipboard value}
# in my case, it was
mkdir -p /opt/homebrew/lib/php/pecl/20200930
Now try to install any pecl extensions.
sudo pecl install redis
After installing any extension, restart php
brew services restart php
Happy coding :)
Trying to install redis extensions for php 7.0 on my high sierra apache.
brew install php-redis - doesn't work.
brew install php#7.0-redis - doesn't work.
brew install php70-redis - doesn't work.
google google google - Homebrew is the wrong approach, use pecl, they say.
pecl search redis shows:
redis 4.0.2 (stable) 4.0.2 PHP extension for interfacing with Redis
so pecl install redis
pecl/redis is already installed and is the same as the released version 4.0.2
install failed
hmm. that's right. And I've put in the reference to the ini file:
cat /usr/local/etc/php/7.0/conf.d/ext-redis.ini
[redis]
extension="/usr/local/lib/php/pecl/20160303/redis.so"
sudo service apachectl -k restart
check phpinfo() - no mention of redis but it does state that it is loading at the ext-redis.ini file.
Definately not loading, since if I try to use it on a php page I get
Fatal error: Uncaught phpFastCache\Exceptions\phpFastCacheDriverCheckException: Redis is not installed or is misconfigured, cannot continue.
What are the steps for getting redis connected in php on macos in 2018?
I was struggling with same issue my issue is solved with bellow steps.
git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install
Add extension=redis.so in your php.ini
my php.ini path is this you can find php.ini path through phpinfo();/usr/local/etc/php/7.0/php.ini
restart your php
brew services restart php#7.0
run make test.
Redis support is enable .Now you can view in phpinfo()
You may want to use "Predis" instead of "Redis" which is an applicative client designed for people that can't make use of php "Redis" extension. However your Redis service must be running and listening for internal connections.
Good day, everyone.
Usually I just using this Official Docs in *nix OS
But now i'm using MacOs and this instructions just doesn't work properly.
In case of pecl install cassandra I got this message:
checking for supported DataStax C/C++ driver version... awk: can't open file /include/cassandra.h
source line number 1
configure: error: not supported. Driver version 2.4.2+ required (found )
ERROR: `/private/tmp/pear/install/cassandra/configure --with-php-config=/usr/bin/php-config' failed
My logic tell me that in that case I need make DataStax C/C++ driver by my own. In folder php-driver\lib I deleting cpp-driver and using this instruction make new and fresh C/C++ driver without errors.
So in official doc it says:
Note The install.sh script will also compile and statically link into the extension a submoduled version of the DataStax C/C++ driver for Apache Cassandra. To use a version of cpp driver that you already have on your system, run phpize, ./configure and make install.
But when i trying to run ./configure from php-drive/ext I got almost the same error:
checking for supported DataStax C/C++ driver version... awk: can't open file /include/cassandra.h
source line number 1
configure: error: not supported. Driver version 2.4.2+ required (found )
Even if I continue and after that error run make install it gives me that log:
/bin/sh /Users/antvirgeo/php-driver/ext/libtool --mode=install cp ./cassandra.la /Users/antvirgeo/php-driver/ext/modules
cp ./.libs/cassandra.so /Users/antvirgeo/php-driver/ext/modules/cassandra.so
cp ./.libs/cassandra.lai /Users/antvirgeo/php-driver/ext/modules/cassandra.la
----------------------------------------------------------------------
Libraries have been installed in:
/Users/antvirgeo/php-driver/ext/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.
----------------------------------------------------------------------
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/
cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST#24727#: Operation not permitted
make: *** [install-modules] Error 1
Libraries have been installed in:
/Users/antvirgeo/php-driver/ext/modules
Even if I adding cassandra extension with that path to php.ini I still got error Class 'Cassandra\SimpleStatement' not found in my project.
php -d="extension=modules/cassandra.so" -m showing that cassandra in list of PHP Modules
What am I doing wrong?
PS: I have ubuntu OS in Parallels with this project with DataStax php driver installed with this instructions works fine.
____upd:
After all instructions of #Fero without ANY ERRORS, command /usr/local/bin/php -i | grep -A 10 "^cassandra$" showing me this:
cassandra
Cassandra support => enabled
C/C++ driver version => 2.4.2
Persistent Clusters => 0
Persistent Sessions => 0
Directive => Local Value => Master Value
cassandra.log => cassandra.log => cassandra.log
cassandra.log_level => ERROR => ERROR
And still the same error - Class 'Cassandra\SimpleStatement' not found
______________UPDATED LAST:
Aaaaand it's working! I wrote output phpinfo(); in my project and realize that apache using other php version and php.ini, where wasn't extension=cassandra.so at all.
You will need to install the DataStax C/C++ driver which is a dependency of the PHP driver. Using these instructions followed by make install after the driver has been successfully built will ensure this dependency is available when building the PHP driver. Using the PHP driver build instructions you will need to make sure that GMP and PHP dev libraries are also available before running pecl install cassandra.
EDIT:
Since you are using El Capitan you are running into issues with the System Integrity Protection and you will need to disable it in order to copy files into /usr. The better and recommended option is to install PHP using Homebrew; however you can also use MacPorts if preferred.
Below are the steps used to reproduce the installation of the PHP driver on a clean OSX El Capitan image with Xcode and Homebrew already installed:
brew install autoconf cmake libuv gmp openssl pcre homebrew/php/php55
brew link homebrew/php/php55
mkdir code
pushd code
git clone https://github.com/datastax/php-driver.git
pushd php-driver
git submodule update --init --recursive
pushd lib/cpp-driver
mkdir build
pushd build
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ..
make -j$(sysctl -n hw.ncpu)
sudo make install
popd
popd
mkdir build
pushd ext
/usr/local/bin/phpize
popd
pushd build
../ext/configure --with-php-config=/usr/local/bin/php-config
make -j$(sysctl -n hw.ncpu)
sudo make install
popd
popd
sudo sh -c 'echo "extension=cassandra.so" >> /usr/local/etc/php/5.5/php.ini'
You can then verify the installation using the following command:
/usr/local/bin/php -i | grep -A 10 "^cassandra$"
NOTE: PHP v5.5 is utilized above since that is the default version that comes with El Capitan; PHP v5.6 and v7.0 can also be used instead.
If you need to install the Cassandra PHP extension on MacOS, you can do this simply by installing it via PECL, without having to do anything with turning on or off System Integrity Protection. I've written a blog post with easy step-by-step instructions. It also includes a link to installing PHP from Homebrew since they removed the Homebrew/php tap back in April of this year.
It also by passes the incorrect instructions given on the DataStax website. In short ...
Install Dependencies (I run these commands one at a time to easily view any messages):
$ brew install autoconf
$ brew install cmake
$ brew install automake
$ brew install libtool
$ brew install gmp
$ brew install libuv
$ brew install openssl
Retrieve and build the C++ driver and then create a build directory inside the cpp-driver folder:
$ git clone https://github.com/datastax/cpp-driver.git --depth=1
$ mkdir cpp-driver/build
$ cd cpp-driver/build
Make and build the driver with a qualified call to OpenSSL:
$ cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..
$ make
$ make install
Now you're good to go to install the Cassandra PHP extension libraries using PECL:
$ pecl install cassandra
Check to make sure that the Cassandra extension was added to your PHP.ini file. If not add it.
[cassandra]
extension="cassandra.so"
Restart Apache and you're off and running with Cassandra in PHP.
If you want more detail on what's happening in the above instructions, refer to my blog post here:
https://medium.com/#crmcmullen/how-to-install-the-cassandra-php-driver-on-macos-10-13-high-sierra-and-10-14-mojave-c18263831ccb
I have MAMP on my machine, and I would like to install memcache for php, because one of my project throws errors like Fatal error: Class 'Memcache' not found.
I installed X-Code from appstore, and libevent, memcached, libmemcached with homebrew.
Then..
cd /tmp; pecl download memcached
gzip -d < memcached-2.2.0.tgz | tar -xvf -
cd memcached-2.2.0; phpize
./configure; make
sudo make install
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20100525/
After that I copied memcached.so and memcache.so to my extension_folder:
/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/
and added extension = memcached.so to my php.ini.
I still get fatal error.. what's the problem?
How to install memcache and memcached on any version MAMP and on any version of php on LINUX/MAC by yourself?
open a terminal
install brew:
ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install memcached
brew install libmemcached
start memchached (daemon) as you whish
To have launchd start memcached at login:
ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents
Then to load memcached now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
Or, if you don't want/need launchctl, you can just run:
/usr/local/opt/memcached/bin/memcached
download the SAME !!! VERSION of php source code from php.net what you want to use with MAMP
extract to /tmp
configure -> make -> make install
when "make install" ends you can see ON THE TERMINAL SCREEN !!! the paths where the php binary was installed on your system
cd that path where your binary located
pecl i memcache
follow onscreen !!! instruction and copy memcache.so
if no instruction, which I doubt it then locate YOUR VERSION of php extensions directory/no-debug-non-zts... or copy memcache.so to here on MAC
/Applications/MAMP/bin/php/[PHP VERSION YOU
USE!!!]/lib/php/extensions/no-debug-non-zts-20060613
add to php.ini (the same version you downloaded and using with mamp) this line: extension=memcache.so;
phpinfo(); and check memcached appears.
OK ITS DONE !!! NOW -> have a beer :)