ADDING MEMCACHED TO CENTOS 6.5+ AND CENTOS 7+ Print

  • 0

Step 1: SSH into your server and fire this command yum install memcached.x86_64
Step 2: Next still in ssh install the memcache php extension pecl install memcache Restart apache: service httpd restart
Step 3: Start memcache by firing this command: memcached -d -m 2048 -l 127.0.0.1 -p 11211 -u nobody Syntax: (d = daemon, m = memory, u = user, l = IP to listen to, p = port)
Step 4: Check your memcached server is running successfully: ps -eaf | grep memcached
Step 5: make it so it comes on at reboot using: chkconfig memcached on
Step 6: In above step three we set the memcache at 2048 ( -m 2048 ) but this is not permanent and will reset back to default which is 64. To make the memcache the size you prefer permanent even after a reboot adjust the setting in the /etc/sysconfig/memcached file and adjust as needed. Restart memcached to see what the memcache size will be after a reboot - service memcached restart The below example shows the /etc/sysconfig/memcached file we are provisioned for 2048 MB's of memcached

Example of memcached configuration file provisioned for 2048 MB's of memcached:

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

NOTE: The last line OPTIONS is set to allow only access to memcached by the server itself basically securing memcached and its data from being manipulated by the outside world.

NOTE: If running CloudLinux be sure to run cagefsctl --force-update to update the php.ini changes to the containers/cages.

NOTE: PHP 7 to get pecl-memcache connected and operating:
1. wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
2. unzip NON_BLOCKING_IO_php7.zip

3. cd pecl-memcache-NON_BLOCKING_IO_php7
4. /opt/cpanel/ea-php70/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php70/root/usr/bin/php-config && make
5. cp modules/memcache.so /opt/cpanel/ea-php70/root/usr/lib64/php/modules/
6. echo 'extension=memcache.so' >/opt/cpanel/ea-php70/root/etc/php.d/memcached.ini
7. service httpd restart Reference: http://stackoverflow.com/a/37760318 and https://forums.cpanel.net/threads/installing-memcache-and-memcached-with-easyapache4.566261/#post-2294161

Was this answer helpful?

« Back

Powered by WHMCompleteSolution