Skip to content

Instantly share code, notes, and snippets.

@irazasyed
Last active November 15, 2023 14:28
Show Gist options
  • Save irazasyed/6066507 to your computer and use it in GitHub Desktop.
Save irazasyed/6066507 to your computer and use it in GitHub Desktop.
How-To: Install Memcache on CentOS (WHM/cPanel)

How-To: Install Memcache on CentOS (WHM/cPanel)

Without wasting much time, Let us get started!

Follow these simple instructions:

  • Step 1: Login into your WHM panel and using easyapache enable Memcache

  • Step 2: SSH into your server and fire this command yum install memcached.x86_64 php-pecl-memcache.x86_64

  • Step 3: Go to Software -> Module Installers -> PHP Pecl, Search for memcache and then install both memcache & memcached

  • Step 4: Restart apache once, Fire: service httpd restart

  • Step 5: Start memcache by firing this command: memcached -d -m 512 -l 127.0.0.1 -p 11211 -u nobody (d = daemon, m = memory, u = user, l = IP to listen to, p = port)

  • Step 6: Check your memcached server is running successfully: ps -eaf | grep memcached

All Done! If everything goes good, You should now be able to use memcached within your application.

Enjoy Caching :)

@pedrofelipe
Copy link

Memcache isn't available on EasyApache, but it worked perfectly. Thanks!

@ethanpil
Copy link

How will this restart memcached if/when the server is rebooted?

@hydn79
Copy link

hydn79 commented Jul 12, 2014

use: chkconfig memcached on

@sebastiansulinski
Copy link

Works a charm. I was struggling to install it all via ssh - I'm running Apache 2.4 with PHP 5.5 and majority of the instructions online are pretty much outdated. Thanks for sharing!

@sebastiansulinski
Copy link

That said - it worked fine with the first server, but now I get:

configure: error: no, sasl.h is not available. Run configure with --disable-memcached-sasl to disable this check
ERROR: `/root/tmp/pear/memcached/configure --with-libmemcached-dir=no' failed
The memcached.so object is not in /usr/local/lib/php/extensions/no-debug-non-zts-20121212

when trying to install memcached.

Any idea?

@rootsami
Copy link

i have the same issue @sebastiansulinski
any update ?.. Have you solved the issue yet!

thanks

@raghavchugh
Copy link

how to set username password for memcahche

@nitriques
Copy link

CENTOS 5.8

BTW, I needed to do this in order to install memcached

Add this to /etc/yum.conf

### Name: RPMforge RPM Repository for RHEL 5 - dag
### URL: http://rpmforge.net/
[rpmforge]
name = RHEL $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el5/en/$basearch/rpmforge
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

[rpmforge-extras]
name = RHEL $releasever - RPMforge.net - extras
baseurl = http://apt.sw.be/redhat/el5/en/$basearch/extras
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge-extras
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-extras
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

[rpmforge-testing]
name = RHEL $releasever - RPMforge.net - testing
baseurl = http://apt.sw.be/redhat/el5/en/$basearch/testing
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge-testing
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-testing
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

From: http://serverfault.com/questions/342826/problems-installing-memcached

Then

wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
rpm --import RPM-GPG-KEY.dag.txt

From: http://www.tecmint.com/install-and-enable-rpmforge-repository-in-rhel-centos-6-5-4/

Then

yum install gcc44 gcc44-c++ libstdc++44-devel
export CC='gcc44'
export CXX='g++44'
cd ~
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure
make && make install
pecl install memcached

From: https://bugs.launchpad.net/libmemcached/+bug/1006230

memcached -d -u nobody -m 1024 127.0.0.1 -p 11211

@migueltavares
Copy link

Thanks alot for the guide, it worked perfectly!

@JamesSimpson
Copy link

MemCache is not available on EasyApache on Apache Version 2.4 though

@brianjking
Copy link

Anyone have any tips on how to get Memcached working when using EasyApache4 Beta?

@chappydboz
Copy link

+1

Anyone have any tips on how to get Memcached working when using EasyApache4 Beta

@dalenoe
Copy link

dalenoe commented Jan 6, 2017

Unfortunately, I am having the same problems @sebastiansulinski

Any ideas?

@itseasy21
Copy link

@dalenoe Try with these steps and it should work fine.

Step 1 - Install SASL:
yum install cyrus-sasl-devel

Step 2 - Compile libmemcached with SASL installed:

cd ~
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure
make && make install

Step 3 - Install PHP Memcached:

pecl install memcached

@faca5
Copy link

faca5 commented May 6, 2017

Hello.

Do you have any idea how to install PHP Memcache in EasyApache 4 for PHP 7? It works for PHP 6.

@sharabh
Copy link

sharabh commented Sep 7, 2018

I see the option to enable Memcache for PHP 7.1 in EasyApache 4. Enabled it on my server and it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment