Easy way to install Memcached and memcache in a cPanel server

Install Memcached and memcache, that’s what we are discussing in this article. In website hosting industry, speed is one of the most important factor that we prefer. The website speed depends upon many factors. Of-course, the speed of the website depends upon the plugins or other third party application installed with it.

Other than the plugins, it mainly depends upon the server performance. Server can be tuned according to our requirement. Enabling caching is one of the factor that includes in optimizing a webserver. Caching technology is a main paramter.

Memcache is a popular type of caching method used. Memcache is an open source caching system to speed-up dynamic website applications. For the proper functioning of Memcache, its daemon memcached is needed. Here I am explaining the installation steps of Memcache and Memcahed in the server.

Introduction to IAAC [Infrastructure As A Code] tools

t’s time that I had to write an article on IAAC. All giant’s infra are now set and manage as IAAC.

I hope you guys are already aware of these tools and you are already started working on that. This is a simple, straight intro to those tools. This will help you to start your journey as an automation engineer.

Now-a-days, all big infra are managing in this way, to reduce the human mistakes and deployment time.

Install Memcached and memcache

Memcache is a type of caching. memcached daemon is needed for the functioning of Memcache. For that, first we need to install memcached daemon.

# yum install memcached

Then, start memcached service

# service memcached start

Example:

root@server [~]# service memcached start
Starting memcached: [ OK ]

Then, install PHP memcache

# pecl install memcache

OR

We can install memcache from the source by following the steps below:

# wget http://pecl.php.net/get/memcache
# cd memcache-3.0.8
# phpize

Then, you can see something like this:


# phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
# ./configure
# make
#make install

Make sure memcache module is present in php.ini file. If not, add the memcache extension in php.ini file.

# echo "extension=memcache.so" >> /usr/local/lib/php.ini

Finally, restart Apache

# service httpd restart

Make sure memcached will be up even after a server reboot:

# chkconfig --levels 235 memcached on

How to check if memcache is installed or not?


root@server [~]# php -m | grep memcache
memcache

That’s it!!!

Zend Opcache

Zend Opcache on direct admin server installation, that’s the topic which we’re discussing here. Before going to the installation tips, let’s see what is Zend Opcache. It’s a modern PHP script caching module which accelerates the PHP performance.

Zend Opcache provides faster PHP execution through Opcode caching and optimization. It improves the performance of PHP by storing the precompiled script byte-code in the shared memory.

 

Some other Installations on cPanel server

Softaculous
nginx as reverse proxy
Suhosin Patch
snoopy logger

Post navigation

Heba Habeeb

Working as a Linux Server Admin, Infopark, Cochin, Kerala.

20 thoughts on “Easy way to install Memcached and memcache in a cPanel server

  1. i’m on a shared hosting, can I install memcached ? If yes, then where do I need to write these codes that you have mentioned above. ?

  2. Yes perfect!! I was in trouble with php memcache, # pecl install memcache solved the problem!!
    Thank’s!!!

  3. Yes another great tutorial – these are brilliant thank you.

    Can varnish and memcache both run together on CentOS 7 or is this a case of either one or the other?

Leave a Reply

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