Install Memcached in PHP8.2-FPM+ With NGINX Ubuntu

0. Don’t forget to install pear for pecl call.

sudo apt-get install -y php8.2-pear

1. After You install the php8.2-fpm you run this command:

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install zlib1g-dev
sudo apt-get -y install libmemcached-dev
sudo pecl install memcached

RESULT:

WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
pecl/memcached can optionally use PHP extension "igbinary" (version >= 2.0)
pecl/memcached can optionally use PHP extension "msgpack" (version >= 2.0)
downloading memcached-3.2.0.tgz …
Starting to download memcached-3.2.0.tgz (90,722 bytes)
…………………done: 90,722 bytes
18 source files, building
running: phpize

When you are shown the following prompts, you will want to press Enter to select the default option for all of the prompts except for enable sasl. When shown the enable sasl prompt, input “no”, then press Enter.

Configuring for:
PHP Api Version: 20220829
Zend Module Api No: 20220829
Zend Extension Api No: 420220829
libmemcached directory [no] : no
zlib directory [no] : no
use system fastlz [no] : no
enable igbinary serializer [no] : no
enable msgpack serializer [no] : no
enable json serializer [no] : no
enable server protocol [no] : no
enable sasl [yes] : non
enable sessions [yes] :

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

sudo bash -c "echo 'extension=memcached.so' >> /etc/php/8.2/fpm/php.ini"
sudo bash -c "echo 'extension=memcached.so' >> /etc/php/8.2/cli/php.ini"
sudo service php8.2-fpm restart

Reference Link

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version