Php install memcache extension

Php install memcache extension

Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: » https://pecl.php.net/package/memcached.

If libmemcached is installed in a non-standard location, use —with-libmemcached-dir=DIR switch, where DIR is the libmemcached install prefix. This directory has to contain the include/libmemcached/memcached.h file.

Zlib is required for compression support. To specify non-standard installation of Zlib, use —with-zlib-dir=DIR switch, where DIR is the Zlib install prefix.

Session handler support is enabled by default. To disable it, use —disable-memcached-session switch.

SASL authentication support is disabled by default. To enable it, use —enable-memcached-sasl switch. This requires that libsasl2 has been installed and that libmemcached has been built with SASL support enabled.

User Contributed Notes 5 notes

Do not lose your time to install it on Ubuntu just trying «sudo apt-get install php5-memcached». There is something you need to do that sure installing memcached. Anyway.

Step 1.
$ sudo apt-get install memcached
Step 2.
$ sudo apt-get install php5-memcached
Step 3.
$ sudo /etc/init.d/apache2 restart

$mc = new Memcached ();
$mc -> addServer ( «localhost» , 11211 );

$mc -> set ( «foo» , «Hello!» );
$mc -> set ( «bar» , «Memcached. » );

$arr = array(
$mc -> get ( «foo» ),
$mc -> get ( «bar» )
);
var_dump ( $arr );
?>

Hoping to help someone.
~Kerem

$ sudo apt-get install memcached
$ sudo apt-get install php-memcached
$ sudo apachectl graceful

$mc = new Memcached();
$mc->addServer(«localhost», 11211);
.

If your server has —enable-json=shared as mine did, this extension requires you to have extension=json.so to load properly.

i’m planning on using membase for my website and i was really struggling to install the memcashed php client on ubuntu with pear, but actually there is an easier way:

Читайте также:  Shallow copy and deep copy in java

$ sudo apt-get install php5-memcached

you dont even need to install the membase server first — this can be done afterwards. hope this helps someone!

At present memcached-1.0.0 does not compile with libmemcached-0.38. This is apparently due to libmemcached chaning the API.

Note: I am encountering the same ‘memcached_st’ has no member named ‘hash’ error on a Debian lenny amd_64 box.

Источник

Php install memcache extension

This » PECL extension is not bundled with PHP. Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: » https://pecl.php.net/package/memcache.

Note:

It’s possible to disable memcache session handler support. The ‘pecl install’ option prompts for this (default is enabled) however when compiling statically into PHP the —disable-memcache-session configure option may be used.

User Contributed Notes 6 notes

I hope this will help someone,
Context: I wanted to use memcache
like this:

but composer suggests me to install the extension
«ext-memcache»: «*»,

but that one didn’t want to work, so I installed

sudo apt install php7.4-memcache
sudo apt install php7.4-memcached

It is very important to note when reading the information supplied by others on this page that there are two *distinct* memcache PHP implementations for the service «memcached».

1) pecl-memcache
2) pecl-memcached

This page is for the first, pecl-memcache.

If you are looking for pecl-memcached information, visit here:

On Slackware, after copilling it, you should copy the file /module/memcache.so to /usr/lib/httpd/modules. Then, the instruction extension=memcache.so must be added into the file /etc/httpd/php.ini

Restart the httpd and it should work!

yum install php-pecl-memcache

#if apt-get, rpm, or yum doesn’t work
cd /usr/src/
wget http://pecl.php.net/get/memcache-2.2.4.tgz
tar -zxvf memcached-2.2.4.tgz
cd memcached-2.2.4
phpize && ./configure —enable-memcache && make
cp modules/memcache.so /usr/lib/php/modules/

# Note: packaged extension modules are now loaded via the .ini files
# found in the directory /etc/php.d
touch /etc/php.d/memcached.ini
echo ‘extension=memcache.so’ > /etc/php.d/memcached.ini

If you have error with libtool version after make — way to install:
phpize —clean && phpize
rm aclocal.m4
aclocal
autoconf
./configure
make
make install
[memcache-2.2.6, gentoo.x86-64]

Читайте также:  Python database with gui

Источник

Memcached

Memcached — это высокопроизводительная система кеширования объектов в памяти, предназначенная в первую очередь для ускорения динамических веб-приложений за счет снижения нагрузки на базу данных.

Установка Memcached

Конфигурация размещается в /etc/sysconfig/memcached

Будем использовать только localhost для доступа к Memcached, для этого укажем «OPTIONS=»-l 127.0.0.1″. Размеры выделяемой памяти указывается в мегабайтах и содержится в опции CACHESIZE, рассчитайте необходимый объем кэша и выделите его:

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="512"
OPTIONS="-l 127.0.0.1"

Проверяем, что слушает именно локально:

# netstat -an | grep «:11211»
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN
udp 0 0 127.0.0.1:11211 0.0.0.0:*

Добавляем Memcached в загрузки при запуске операционной системы:

Просмотр текущего статуса Memcached:

Установка PHP-расширения

Система управления работает как с расширением memcache, так и memcached, рекомендуется использовать memcached.

Установка расширения Memcached (для PHP 5.6 — 7.x)

Установка расширения Memcache (для PHP до версии 5.6), устаревшее

конфигурационный файл будет размещен в /etc/php.d/memcache.ini, примерное содержимое:

; ----- Enable memcache extension module
extension=memcache.so

; ----- Options for the memcache module

; Whether to transparently failover to other servers on errors
;memcache.allow_failover=1
; Data will be transferred in chunks of this size
;memcache.chunk_size=32768
; Autocompress large data
;memcache.compress_threshold=20000
; The default TCP port number to use when connecting to the memcached server
;memcache.default_port=11211
; Hash function
;memcache.hash_function=crc32
; Hash strategy
;memcache.hash_strategy=consistent
; Defines how many servers to try when setting and getting data.
;memcache.max_failover_attempts=20
; The protocol : You need a memcached >= 1.3.0 to use the binary protocol
; The binary protocol results in less traffic and is more efficient
;memcache.protocol=ascii
; Redundancy : When enabled the client sends requests to N servers in parallel
;memcache.redundancy=1
;memcache.session_redundancy=2
; Lock Timeout
;memcache.lock_timeout = 15

; ----- Options to use the memcache session handler

; Use memcache as a session handler
;session.save_handler=memcache
; Defines a comma separated of server urls to use for session storage
;session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

Источник

Memcache PHP Extensions for Memcached Caching Daemon

Memcached (Memcache Daemon) is a caching daemon designed especially for dynamic web applications to decrease database load by storing objects in memory. It is commonly used to speed up dynamic database-driven websites by caching data and objects in server memory to reduce the number of times the data source must be read. Memcached is free and open-source software licensed under the Revised BSD license.

Читайте также:  Структура массива си шарп

This article will cover PHP extensions that allow you to work with Memcached. There are two PHP Memcache extensions available from the PHP Extension Community Library: PHP Memcached and PHP Memcache.

PHP Memcached vs PHP memcache

memcache vs memcached

These two PHP extensions are not identical. PHP Memcache is older, very stable but has a few limitations. The PHP Memcache module utilizes the daemon directly, while the PHP Memcached module uses the libMemcached client library and contains some added features.

You can compare features and differences between them here.

Installing Memcache Daemon + PHP Memcache or PHP Memcached

Before selecting a PHP extension, be sure to install the Memcache daemon:

apt update apt install memcached

After installing Memcached, open the configuration file for Memcached and make any changes:

Exit and save the configuration file, and then restart Memcached. Remember to set the Memcache daemon to start on server boot.

systemctl start memcached ​systemctl enable memcached ​ systemctl status memcached

Memcached is already started and enabled upon installation.

Note: You can search your Linux distribution’s package manager and install from there.

Next, let’s install a PHP Memcache extension.

PHP Memcache

wget https://pecl.php.net/get/memcache-x.x.tgz tar xf memcache-x.x.tgz cd memcache-x.x phpize ./configure make && make install

Then add memcache.so to your php.ini file:

PHP Memcached

yum install cyrus-sasl-devel zlib-devel gcc-c++ wget https://launchpad.net/libmemcached. +download/libmemcached-x.x.tar.gz tar -xvf libmemcached-x.x.tar.gz cd libmemcached-x.x ./configure --disable-memcached-sasl make make install

Then install PHP Memcached:

wget https://pecl.php.net/get/memcached-x.x.tgz tar xf memcached-x.x.tgz cd memcached-x.x phpize ./configure make && make install

Then add memcached.so to your php.ini file:

You will need to connect your PHP application to Memcached. For example, using W3 Total Cache with WordPress, Memcached module with Drupal, Magento config, etc.

Finally, restart Memcached and, if necessary, Apache (and/or Nginx, etc.).

If you would like to view stats of hit rate etc., you can download Memcache PHP stats. Which will look something like this…

MEMCACHE STATS

Published: Aug 29, 2015 | Last updated: August 9th, 2021

Источник

Оцените статью