In the examples shown, replace "5.X" with your app's PHP version (for example, "5.4"). To install a PECL extension for multiple PHP versions, repeat the PECL extension installation for each PHP version.
Two different extensions are available that provide access to Memcached from within your PHP scripts. They provide similar functionality but have different authors.
These PHP extensions provide client access to the Memcached server. They are not Memcached itself. Memcached is a server written in C that listens on port 11211. When you use the PHP client extensions, they will communicate with the Memcached server.

Memcache

For instructions on the Memcached extension (with a d), see the next section below.

To install this extension, SSH in to your server as root and run the following command:

sudo apt-get install gcc make autoconf libc-dev pkg-config
sudo apt-get install zlib1g-dev
sudo pecl5.X-sp install memcache

Once installed, create a configuration file for the extension and restart PHP.

sudo bash -c "echo extension=memcache.so > /etc/php5.X-sp/conf.d/memcache.ini"
sudo service php5.X-fpm-sp restart

Installing Memcache on PHP 7.0

The Memcache extension does not currently work with PHP 7.0. If you attempt to install it on PHP 7.0, you will encounter errors building the extension. As soon as the extension is updated to work with PHP 7.0, you will be able to install it.

Memcached

For instructions on the Memcache extension (without ad), see the previous section above.

Installing Memcached on PHP 5.4, 5.5, and 5.6

To install this extension, SSH in to your server as root and run the following command:

sudo apt-get install gcc make autoconf libc-dev pkg-config
sudo apt-get install zlib1g-dev
sudo apt-get install libmemcached-dev
sudo pecl5.X-sp install memcached

When you are shown the prompt

libmemcached directory [no] :

type or paste the following text exactly as shown and press Enter.

no --disable-memcached-sasl

That is, the entire line you'll see on your screen will be as follows once you press Enter.

libmemcached directory [no] : no --disable-memcached-sasl

Once installed, create a configuration file for the extension and restart PHP by running the following command as root

sudo bash -c "echo extension=memcached.so > /etc/php5.X-sp/conf.d/memcached.ini"
sudo service php5.X-fpm-sp restart

Installing Memcached on PHP 7.0

To install this extension for PHP 7.0, SSH in to your server as root and run the following commands:

sudo apt-get install gcc make autoconf libc-dev pkg-config
sudo apt-get install zlib1g-dev
sudo apt-get install libmemcached-dev
git clone https://github.com/php-memcached-dev/php-memcached
cd php-memcached
git checkout php7
/opt/sp/php7.0/bin/phpize
PATH=/opt/sp/php7.0/bin:$PATH ./configure --disable-memcached-sasl
make
sudo make install
sudo bash -c "echo extension=memcached.so > /etc/php7.0-sp/conf.d/memcached.ini"
sudo service php7.0-fpm-sp restart

Installing Memcached on PHP 7.1

To install this extension for PHP 7.1, SSH in to your server as root and run the following commands:

sudo apt-get install gcc make autoconf libc-dev pkg-config
sudo apt-get install zlib1g-dev
sudo apt-get install libmemcached-dev
git clone https://github.com/php-memcached-dev/php-memcached
cd php-memcached
git checkout php7
/opt/sp/php7.1/bin/phpize
PATH=/opt/sp/php7.1/bin:$PATH ./configure --disable-memcached-sasl
make
sudo make install
sudo bash -c "echo extension=memcached.so > /etc/php7.1-sp/conf.d/memcached.ini"
sudo service php7.1-fpm-sp restart

Verifying the Installation

You can verify the memcached extension is installed correctly by running this command:

phpX.Y-sp -i | grep -i "memcached support"

You should see output like the following:

memcached support => enabled
Alert: For Control Panel Help & Tutorials, click here: Panel Tutorials
Was this answer helpful? 1 Users Found This Useful (1 Votes)

Powered by WHMCompleteSolution