How to enable igbinary with memcached installed first - php

I have memcached installed with libmemcached. Also I have installed igbinary.
This is my php.ini:
; Directory in which the loadable extensions (modules) reside.
;extension_dir = "./"
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613/"
extension=apc.so
apc.enabled=1
apc.shm_size=128M
extension=memcached.so
session.save_handler=memcached
session.save_path="127.0.0.1:11211"
extension=igbinary.so
session.serialize_handler=igbinary
igbinary.compact_strings=On
.
When I run phpinfo() i see that igbinary is enabled, but not for memcached:
apc
Serialization Support php, igbinary
igbinary
igbinary support enabled
igbinary version 1.1.1
igbinary APC serializer ABI 0
Directive Local Value Master Value
igbinary.compact_strings On On
Phpinfo() about memcached:
memcached
memcached support enabled
Version 1.0.2
libmemcached version 0.51
Session support yes
igbinary support no
That last line: igbinary support thats the question. Oddly enough, as you can see under the heading apc there is stated: Serialization Support php, igbinary.
So do someone know why I cannot enable igbinary for memcached?
Thanks!

You can check the Memcached::HAVE_IGBINARY constant to see if your memcached extension was compiled using --enable-memcached-igbinary.
Source: http://php.net/manual/en/memcached.constants.php
Memcached::OPT_SERIALIZER
Specifies the serializer to use for serializing non-scalar values. The
valid serializers are Memcached::SERIALIZER_PHP or
Memcached::SERIALIZER_IGBINARY. The latter is supported only when
memcached is configured with --enable-memcached-igbinary option and
the igbinary extension is loaded.
Type: integer, default: Memcached::SERIALIZER_PHP.
Memcached::HAVE_IGBINARY
Indicates whether igbinary serializer support is available.
Type: boolean.

You can't enable it because PECL memcached was not built with '--enable-memcached-igbinary'
PECL install does not take this as a flag, so here is how you can build pecl memcached with it (following example is on ubuntu as root)
#if you have libmemcached-dev < 1.0.X need to run: sudo apt-get purge libmemcached-dev
apt-get install libevent-dev
pecl install igbinary
#cant do sudo pecl install memcached-2.1.0 cuz it wont let me use igbinary
#compiling manually per http://www.neanderthal-technology.com/2011/11/ubuntu-10-install-php-memcached-with-igbinary-support/
#install libmemcached v 1.0.X for pecl memcached 2.1.0
cd /tmp
libmemcached_ver="1.0.15"
wget https://launchpad.net/libmemcached/1.0/${libmemcached_ver}/+download/libmemcached-${libmemcached_ver}.tar.gz
tar xzvf libmemcached-${libmemcached_ver}.tar.gz
cd libmemcached-${libmemcached_ver}/
./configure
make
make install
cd ../
rm -r libmemcached-${libmemcached_ver}
#install memcached PECL extension
pecl_memcached_ver="2.1.0"
pecl download memcached-${pecl_memcached_ver}
tar xzvf memcached-${pecl_memcached_ver}.tgz
cd memcached-${pecl_memcached_ver}/
phpize
./configure --enable-memcached-igbinary
make
make install
cd ..
rm -r memcached-${pecl_memcached_ver}
echo "extension=igbinary.so" > /etc/php5/fpm/conf.d/igbinary.ini
echo "extension=memcached.so" > /etc/php5/fpm/conf.d/memcached.ini
#now restart your PHP server
Load up a phpinfo() page and you should now see 'igbinary support: yes' under memcached section.

If you work on a Mac and use MacPorts, you can install the php5-memcached extension with igbinary support with this command:
sudo port install php5-memcached +igbinary
The +igbinary specifies a variant of the php5-memcached port.
That command will install an igbinary-enabled memcached extension on your Mac.
You can read more about port variants here: http://guide.macports.org/#using.variants

It's now possible to pass configuration options to pecl install (see the PECL manual)
Here's how you'd install memcached with the igbinary serializer, and all other options left at their default values:
pecl install --configureoptions 'with-libmemcached-dir="no" with-zlib-dir="no" with-system-fastlz="no" enable-memcached-igbinary="yes" enable-memcached-msgpack="no" enable-memcached-json="no" enable-memcached-protocol="no" enable-memcached-sasl="yes" enable-memcached-session="yes"' memcached
The full list of options is defined here (look for the <configureoption> tags): https://github.com/php-memcached-dev/php-memcached/blob/master/package.xml

Related

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. I use MacOS High Sierra and php#7.1 installing using homebrew. During the installation of memcached module for php using command
pecl install memcached
I received the errors:
checking for zlib location... configure: error: memcached support
requires 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
But I have installed zlib. I can't find a way how to install memcached module after the changes in homebrew repository.
pecl bundle memcached
Change to the directory it output
phpize
Make sure libmemcached and zlib are installed (brew install libmemcached zlib)
Get the zlib directory (brew list zlib)
./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/ (replace the zlib path with the one from the previous command)
make
make install
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
[memcached]
extension=memcached.so
Verify you installed the module php -m should show you memcached in the outputted list
You can use env variable PHP_ZLIB_DIR to tell it where zlib is.
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
Install pkg-config and zlib using brew install pkg-config zlib
Check Php Version for which you installing should be linked. php -v tells you which php version is active for cli.
pecl config-get ext_dir will tell you which version configuration files are set.
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
Restart your php and 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.
Note : Am using MacPro M1 silicon chip notebook. Installed using homebrew. struggle a lot to fix this issue.

How to enable LDAP extension for PHP in Ubuntu

I am trying to enable LDAP for PHP5.6 on Ubuntu 16.04. I have tried the following steps
- sudo apt-get install php5-ldap
- sudo enmod ldap
- sudo php5enmod ldap
but still I am unable to get my ldap related functions working with PHP
you need to restart your apache (systemctl restart apache2). Apache has its very own single php-process running*. The php-configuration is only reload if apache restarts this process. You can check your active configuration with phpinfo
* this is very simplified and depends on the apache MPM-Module you are using.
sudo apt-get install php-ldap
/etc/init.d/apache2 restart
#baig772 answered their own question but they didn't post it as an answer.
latest ubunutu php-ldap was not working I tried installing apt-get install php7.0-ldap which is not working, then I download deb https://debian.pkgs.org/sid/debian-main-amd64/php7.2-ldap_7.2.4-1+b2_amd64.deb.html
wget http://ftp.br.debian.org/debian/pool/main/p/php-defaults/php-common_49_all.deb
wget http://ftp.us.debian.org/debian/pool/main/p/php7.0/php7.0-ldap_7.0.29-1+b2_amd64.deb
wget http://ftp.us.debian.org/debian/pool/main/u/ucf/ucf_3.0038_all.deb
then..
apt install ./php7.2-common_7.2.4-1+b2_amd64.deb
apt install ./php7.2-ldap_7.2.4-1+b2_amd64.deb
...
once it is installed confirmed by running the
apt-cache pkgnames | grep ldap | grep php
php-symfony-ldap
php7.2-ldap
php-net-ldap2
php-net-ldap3
check php enabled modules
:/usr/lib/php/7.2# php -m
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
it does not have ldap module..
so copied .so files
:/usr/local/etc/php# cp /usr/lib/php/20170718/ldap.so /usr/local/lib/php/extensions/no-debug-non-zts-20170718/
enable apache ldap " a2enmod ldap"
php-m
now it has ldap module enabled.
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
json
ldap
libxml
mbstring
restart apache and checked in info.php.
/etc/init.d/apache2 stop
/etc/init.d/apache2 start

Ubuntu pecl install pecl_http fail

I'm trying to install this extension but it fails in the configuration phase. I'm on ubuntu 12.04 and I have just installed these packages:
libcurl3-openssl-dev
php-http
libpcre3-dev
libcurl3
php-pear
php5-dev
PHP version:
PHP 5.3.10-1ubuntu3.14 with Suhosin-Patch (cli) (built: Sep 4 2014 07:08:49)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
Here is the log of the installation command:
sudo pecl install pecl_http
downloading pecl_http-2.1.1.tgz ...
Starting to download pecl_http-2.1.1.tgz (158,441 bytes)
.................................done: 158,441 bytes
64 source files, building
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
Enable extended HTTP support [yes] :
where to find zlib [/usr] :
where to find libcurl [/usr] :
where to find libevent [/usr] :
building in /tmp/pear/temp/pear-build-rootqE2kgU/pecl_http-2.1.1
running: /tmp/pear/temp/pecl_http/configure --with-http --with-http-zlib-dir=/usr --with-http-libcurl-dir=/usr --with-http-libevent-dir=/home/gare88/Lib/Php/libevent-2.0.21-stable/
checking for grep that handles long lines and -e... /bin/grep
[... cut...]
checking for zlib.h... found in /usr
checking for zlib version >= 1.2.0.4... 1.2.3.4
checking for curl/curl.h... found in /usr
checking for curl-config... found: /usr/bin/curl-config
checking for curl version >= 7.18.2... 7.22.0
checking for SSL support in libcurl... yes
checking for openssl support in libcurl... no
checking for gnutls support in libcurl... no
checking for ares support in libcurl... no
checking for bundled SSL CA info... /etc/ssl/certs/ca-certificates.crt
checking for event2/event.h... not found
configure: WARNING: continuing without libevent support
checking for ext/raphf support... no
configure: error: Please install pecl/raphf and activate extension=raphf.so in your php.ini
ERROR: `/tmp/pear/temp/pecl_http/configure --with-http --with-http-zlib-dir=/usr --with-http-libcurl-dir=/usr --with-http-libevent-dir=/usr' failed
It seems that is a problem with pecl/raphf so I tried:
sudo pecl install raphf
pecl/raphf is already installed and is the same as the released version 1.0.4
install failed
At the end of php.ini file located on /etc/php5/apache2/php.ini
I added the line:
extension=raphf.so
extension=propro.so
extension=http.so
Is there anything else I can try?
You need to install php-raphf from your package manager.
for me i installed the module using the following. In your case you should be able to switch out yum for apt-get.
sudo yum install php-raphf
sudo yum install php-propro
sudo pecl install pecl_http
The you will need to add extension = http.so to your php.ini file. But it looks like you have already done that.
pecl does not actually install the .so file that you are looking for.
if you have ubuntu 13 or 14, try pecl install pecl_http-1.7.6 as newer versions still do not load for some reason.
On Ubuntu 12.04.5 LTS this worked for me:
First install some prerequisites needed for compilation:
sudo apt-get install php-http
sudo apt-get install php5-dev
sudo apt-get install libcurl3
sudo apt-get install libpcre3-dev
sudo apt-get install libcurl4-openssl-dev
sudo pecl install raphf
sudo pecl install pecl_http-1.7.6
after that go to the folder /usr/lib/php5/modules and check if the libraries are there: raphf.so, propro.so and http.so.
If your php.ini (at /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini) does not contain these extensions, add them:
extension=http.so
extension=propro.so
extension=raphf.so
or using the absolute path to the files, e.g. extension=/usr/lib/php5/modules/http.so.
And as last step restart your webserver, thus loading the new configuration:
sudo service apache2 reload
Just to add to #mschuett's answer, I found that when I got the same error as the OP that changing my extension reference in the php.ini did the trick.
extension=raphf.so
to
extension=/usr/lib/php5/20121212/raphf.so
then
sudo pecl install pecl_http
Also setting the following will keep you from having to hand edit your php.ini file when a pecl installation wants to modify it:
pear config-set php_ini /etc/php5/apache2/php.ini
pecl config-set php_ini /etc/php5/apache2/php.ini
NOTE: This worked for Ubuntu 14.04 LTS.
run command
sudo yum install php-raphf
sudo yum install php-propro
sudo pecl install pecl_http
etc/phph5/apache2/conf.d
add two file
raphf.ini
add content
extension=raphf.so
solr.ini
add content
extension=raphf.so
add in php.ini file
extension=http.so extension=propro.so
extension=raphf.so
or
extension=/usr/lib/php5/20121212/raphf.so
extension=solr.so
I bump into this issue while trying to install pecl_http-2.6.0, raphf-1.1.2 and propro-1.0.2 on Ubuntu 16.04 and php-fpm5.6. I can't use apt to install raphf and propro (as #mschuett suggested) because apt can only install raphf 2.0.0 and propro 2.1.0 which works only for PHP 7.
I resolve the problem with the following steps without needing to update the php.ini nor using apt.
First of all, to get php-fpm to load a new extension, an .ini file must be added to /etc/php/5.6/mods-available. Then use phpenmod to enable the extension.
So to install and enable raphf-1.1.2,
$ pecl install raphf-1.1.2
$ echo "extension=raphf.so" >> /etc/php/5.6/mods-available
$ phpenmod raphf
Note that you might need sudo for these commands.
Similarly, for propro-1.0.2
$ pecl install raphf-1.0.2
$ echo "extension=raphf.so" >> /etc/php/5.6/mods-available
$ phpenmod raphf
If you use php -m to view all the loaded extensions, you should see raphf and propro in the list.
Now you can install pecl_http-2.6.0 with
$ pecl install pecl_http-2.6.0
The installation should complete successfully.
$ pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
pecl_http 2.6.0 stable
propro 1.0.2 stable
raphf 1.1.2 stable
If you are using pecl like me, you might see warning such as:
install ok: channel://pecl.php.net/pecl_http-2.6.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=http.so" to php.ini
which happens because the php_ini config of my pear and pecl aren't set.

The json extension is missing. Please check your PHP configuration

I install PHP5.6.0 on Ubuntu 13.10 x64 from this
https://launchpad.net/~ondrej/+archive/php5-5.6a
then I installed phpmyadmin when I am trying to lunch phpmyadmin I got this message
The json extension is missing. Please check your PHP configuration.
my PHP modules:
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
libxml
mbstring
mcrypt
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
then when i use this command to install php-json
sudo apt-get install php5-json
I got this
The following packages have unmet dependencies:
php5-json : Depends: phpapi-20121212
E: Unable to correct problems, you have held broken packages.
How can I fix this problem?
It looks like you are install PHP5 from a custom repo. I would remove PHP and remove that repo.
sudo apt-add-repository --remove ppa:ondrej/php5-5.6
sudo apt-get update
now install php
sudo apt-get install php5-common php5-json
Below solution worked for me-
cd /etc/php5/mods-available
vi json.ini
In this file make below changes
priority=20
extension=json.so
Incase if json.ini file is not there, create the file with contents as
priority=20
extension=json.so
The problem seems to me to be because of Ubuntu's default permissions for the php.ini files. It only allows Root to read/execute the directories holding the in files.
You can easily verify this by observing that when you execute:
sudo php -m
You see all installed and enabled modules listed correctly.
The solution to this I have found on ubuntu distros is to:
sudo chmod a+rx /etc/php5/cli/
sudo chmod a+rx /etc/php5/cli/php.ini
sudo chmod a+rx /etc/php5/cli/conf.d/
Then you can easily verify by running:
php -m
It worked for me after loading the installed modules json and mcrypt.
$ sudo php5enmod json && sudo php5enmod mcrypt $ sudo service apache2 restart
Go to http://yourserver/phpmyadmin and take a look to check if it works.

Error compiling mysqlnd_qc with apc

Running the command pecl install mysqlnd_qc to install the caching with APC enabled I receive the following error:
configure: error: APC is onlysupported if both APC and MySQL Query Cache are compiled statically
ERROR: `/var/tmp/mysqlnd_qc/configure --enable-mysqlnd-qc-apc=yes --enable-qc-memcache=no --enable-qc-sqlite=no' failed
Without the APC enabled it compiles fine...
PHP version: 5.3.17
Running on Amazon RDS.
What does it mean to compile APC and MySQL Query Cache statically?
How is it done?
Update 1:
As I haven't managed to compile mysqlnd_qc with APC, I tried compiling it with memcached.
Here was an interesting issue. The ./configure command didn't recognize the the option the pecl gave for memcache. I found out that the option was entered incorrectly...
So I killed the pecl installation when it was asking for the options and ran the following commands myself:
sudo ./configure --enable-mysqlnd-qc-memcache --with-libmemcached-dir=/usr/
sudo make
sudo make install
So with memcached it now works.
If running on Fedora (I guess also RedHat and CentOS) there is available a rpm:
sudo yum install php-pecl-mysqlnd-qc
Update 2:
I managed to compile with APC, see the detailed answer below.
Well found the solution:
Here is what I did:
Get php 5.3.17:
wget https://github.com/php/php-src/archive/PHP-5.3.17.zip
unzip PHP-5.3.17.zip
Get mysqlnd_qc:
wget http://pecl.php.net/get/mysqlnd_qc-1.1.1.tgz
tar -zxvf http://pecl.php.net/get/mysqlnd_qc-1.1.1.tgz
mkdir -p php-src-PHP-5.3.17/ext/mysqlnd_qc
cp -R mysqlnd_qc-1.1.1/* php-src-PHP-5.3.17/ext/mysqlnd_qc
Get APC:
wget http://pecl.php.net/get/APC-3.1.13.tgz
tar -xzvf APC-3.1.13.tgz
mkdir -p php-src-PHP-5.3.17/ext/apc
cp -R APC-3.1.13/* php-src-PHP-5.3.17/ext/apc/
Compile: (maybe don't need all on other systems)
sudo yum install bison
sudo yum install libxml2 libxml2-devel
sudo yum install autoconf213
sudo yum install httpd-devel
sudo yum install bzip2 lbzip2 bzip2-libs bzip2-devel
export PHP_AUTOCONF=/usr/bin/autoconf-2.13
./buildconf --force
make clean && make
(for me the linkage failed and had to add '-lpthread' to linkage)
make test
sudo make install
I used also the following 2 commands but I don't remember for what and when...
phpize
aclocal
Run the same ./configure as in phpinfo and add these options:
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-qc --enable-mysqlnd-qc-apc --enable-mysqlnd --enable-apc --enable-static=apc
All the --with must be replaced.
It looks like you have to compile from source giving the right .configure options.
pecl install just gives you a .so, which is a dynamic module extension, you can add via php.ini
So if you really need mysqlnd_qc with apc (do you?), you have to get the php src, and compile it
with the needed modules.
If you donĀ“t need it, just say no or hit return when pecl install mysqlnd_qc ask you about it.

Categories