“Php连接有密码的memcached服务”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
(创建页面,内容为“php连接有密码的 memcached服务 =我的环境 = <pre>ubuntu 18.04 xampp 7.3.12 有密码的memcached服务 相关信息 '192.168.10.214:11211'), 'memcach…”)
 
第1行: 第1行:
 
php连接有密码的 memcached服务
 
php连接有密码的 memcached服务
 
  
 
=我的环境 =
 
=我的环境 =
 
  <pre>ubuntu 18.04  xampp  7.3.12
 
  <pre>ubuntu 18.04  xampp  7.3.12
 
 
有密码的memcached服务 相关信息
 
有密码的memcached服务 相关信息
 
'192.168.10.214:11211'), 'memcached', 'RV3kEjX5Ug5ufTKO'</pre>
 
'192.168.10.214:11211'), 'memcached', 'RV3kEjX5Ug5ufTKO'</pre>
 
  
 
=ins sasl 库=
 
=ins sasl 库=
第23行: 第20行:
 
     libsasl2-modules</pre>
 
     libsasl2-modules</pre>
  
 
+
=ins libmemcached=
=ins libmemcached
 
 
<pre>
 
<pre>
 
wget  -c  https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
 
wget  -c  https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
第90行: 第86行:
 
/opt/lampp/bin/php -m  | grep mem
 
/opt/lampp/bin/php -m  | grep mem
 
memcached
 
memcached
 
  
 
或者直接 phpinfo
 
或者直接 phpinfo
 
 
<pre>
 
<pre>
 
=troubleshooting=
 
=troubleshooting=

2020年2月18日 (二) 07:19的版本

php连接有密码的 memcached服务

我的环境

ubuntu 18.04  xampp  7.3.12
有密码的memcached服务 相关信息
'192.168.10.214:11211'), 'memcached', 'RV3kEjX5Ug5ufTKO'

ins sasl 库

 apt-get install -y  \
    libevent-dev \
    libsasl2-2 \
    sasl2-bin \
    libsasl2-2 \
    libsasl2-dev \
    wget \
    pwgen \
    gcc \
    make \
    libsasl2-modules

ins libmemcached

wget  -c  https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar xvf libmemcached-1.0.18.tar.gz 
cd libmemcached-1.0.18/
   
  ./configure --prefix=/usr/local/libmemcached --enable-sasl
  
  Ubuntu 18.04 LTS使用GCC 7.3版本,编译libmemcached失败。

clients/memflush.cc:42:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   if (opt_servers == false)
                      ^~~~~
clients/memflush.cc:51:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     if (opt_servers == false)
                        ^~~~~

编译前需要打个补丁,参见: https://bugs.launchpad.net/libmemcached/+bug/1663985 https://src.fedoraproject.org/cgit/rpms/libmemcached.git/plain/libmemcached-build.patch



wget https://src.fedoraproject.org/rpms/libmemcached/raw/HEAD/f/libmemcached-build.patch

libmemcached-1.0.18# patch -p1 < libmemcached-build.patch

make -j3 && make install 


ins php memcached



memcached 	PHP extension for interfacing with memcached via libmemcached library


wget -c  https://pecl.php.net/get/memcached-3.1.5.tgz


apt install m4 autoconf


tar xvf memcached-3.1.5.tgz 

cd /opt/memcached-3.1.5/
/opt/lampp/bin/phpize
 ./configure --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached-sasl --with-php-config=/opt/lampp/bin/php-config
 
 make -j3  
  make install 
Installing shared extensions:     /opt/lampp/lib/php/extensions/no-debug-non-zts-20180731/

vim  /opt/lampp/etc/php.ini
; add 

extension=memcached.so 
memcached.use_sasl = 1

检验 
/opt/lampp/bin/php -m  | grep mem
memcached

或者直接 phpinfo
<pre>
=troubleshooting=
<pre>
装cyrus-sasl-devel软件包然后重新编译libmemcached。

重新libme 再安装一次吧 
要先打包时一样安装 sasl之类的
configure: error: no, libmemcached built with sasl disabled. Run configure with --disable-memcached-sasl or update libmemcached with sasl support