Installing memcached with CentOS 7 (EasyApache4)
Memcached is a distributed, high-performance, in-memory caching system that is primarily used to speed up sites that make heavy use of databases. It can however be used to store objects of any kind. Nearly every popular CMS has a plugin or module to take advantage of memcached, and many programming languages have a memcached library, including PHP, Perl, Ruby, and Python. Memcached runs in memory and is thus quite speedy, since it does not need to write data to disk.
These instructions are intended specifically for installing Memcached on a CentOS 7 with PHP 7.1
Step #1 Install Memcached
First, clean-up yum:
As a matter of best practice we"ll update our packages:
Installing Memcached and related packages is now as simple as running just one command:
Next, install libsasl2
Now, install libmemcached:
Step #2: PECL Memcached extension
Add to your php.ini file to add:
45443 Exit and save the configuration file, and then restart Memcached.
Step 3: Configure Memcached to Start on Boot And then start Memcached:
Be sure that Memcached starts at boot:
To check the status of Memcached:
To stop Memcached:
# yum clean allAs a matter of best practice we"ll update our packages:
# yum updateInstalling Memcached and related packages is now as simple as running just one command:
# yum install libevent
# yum install memcachedNext, install libsasl2
# yum install cyrus-sasl-develNow, install libmemcached:
# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
# tar -xvzf libmemcached-1.0.18.tar.gz
# cd libmemcached-1.0.18
# ./configure
# make && make installStep #2: PECL Memcached extension
# pecl install memcachedAdd to your php.ini file to add:
extension=memcached.so45443 Exit and save the configuration file, and then restart Memcached.
# systemctl restart memcachedStep 3: Configure Memcached to Start on Boot And then start Memcached:
# systemctl start memcachedBe sure that Memcached starts at boot:
# systemctl enable memcachedTo check the status of Memcached:
# systemctl status memcachedTo stop Memcached:
# systemctl stop memcached-
Installing PECL Memcache on a CentOS 7 with PHP 7.1 # wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
# unzip NON_BLOCKING_IO_php7.zip
Move pecl-memcache-NON_BLOCKING_IO_php7 to pecl-memcache_php71# mv pecl-memcache-NON_BLOCKING_IO_php7 pecl-memcache_php71
Go to the given directory /pecl-memcache_php71# cd pecl-memcache_php71
You can run following commands to install PECL Memcache.# /opt/cpanel/ea-php71/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php71/root/usr/bin/php-config && make
# cp modules/memcache.so /opt/cpanel/ea-php71/root/usr/lib64/php/modules/
Add to your php.ini file to add: extension=memcached.so OR run following commands# echo 'extension=memcache.so' >/opt/cpanel/ea-php71/root/etc/php.d/memcached.ini
# service httpd restart
You can confirm both the memcache and memcached extensions are installed.# php -m |grep mem0
Please sign in to leave a comment.
Comments
1 comment