• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » How To Install Memcached on Ubuntu Server And Configure WordPress

By Abhishek Ghosh September 1, 2018 9:27 am Updated on September 1, 2018

How To Install Memcached on Ubuntu Server And Configure WordPress

Advertisement

In previous guide, we installed APC cache on Ubuntu 18.04. Here Are The Steps On How To Install Memcached on Ubuntu Server 16.04, 18.04 And Configure WordPress To Optimize Page Loading Speed. APC is an opcode cache. APC cache chunks of PHP code and stores it in RAM. When we need to run that same piece of code again APC already cached it and runs from memory at lightning fast. An opcode cache is one that compiles the plain PHP code into machine code (opcode) and then stores it in the compiled form for future requests until it detects the original PHP file has changed. This means that PHP does not have to run this compile step on every single request, saving some time.

Memcache or Redis are in-memory data-store, used as a cache for your WordPress site data. Although both are cache system and sounds closer, they are technically not same. Everything really depends on your server. A cluster of small servers at lower cost can distribute load and make site load loading almost instantly. APC does not share the cache with other servers but possibly it is faster to cache code.

In short, memcached is a distributed caching system, whereas APC cache is a non-distributed cache and mainly an opcode cache. If your WordPress live on different webservers for loadbalancing then you have to use memcached for distributed caching. If not, you can stick to APC cache. You should always use asome opcode cache. You can/should use both of them for different purposes.

Advertisement

---

 

Steps of How To Install Memcached on Ubuntu Server

 

You should have installed Apache2, PHP on Ubuntu 16.04 or 18.04 in our described way. SSH as root. Run :

Vim
1
2
apt update -y
apt upgrade -y

First install the dependencies, search apt with php72-devel to find some php-devel for your version of PHP :

Vim
1
apt install make php72-devel gcc glibc-devel zlib-devel libmemcached-dev libmemcached11 git build-essential

Install memcache :

Vim
1
2
apt install memcached
service memcached start

Install PHP memcached (d means daemon) :

Vim
1
2
pecl install memcached
# sudo apt install php-memcached

Add this line to php.ini under the php version you installed memcached php (like :/etc/php/7.0/mods-available for PHP 7.0) or under Apache’s php.ini directory (like /etc/php/7.0/apache2/php.ini) :

Vim
1
extension=memcached.so

If you have Apache2 running, then reload :

Vim
1
service apache2 restart

If you run :

Vim
1
php -i | grep "memcached support"

You’ll get :

Vim
1
memcached support => enabled

Run :

Vim
1
echo "stats settings" | nc localhost 11211

11211 is the default port where memcached runs. Run :

Vim
1
php -r 'phpinfo();' | grep -i 'memcached'

You’ll get output like this :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/etc/php/7.2/cli/conf.d/20-memcached.ini,
memcached
memcached support => enabled
libmemcached version => 1.0.18
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.serializer => php => php
memcached.sess_binary => 0 => 0
memcached.sess_connect_timeout => 1000 => 1000
memcached.sess_consistent_hash => 0 => 0
memcached.sess_lock_expire => 0 => 0
memcached.sess_lock_max_wait => 0 => 0
memcached.sess_lock_wait => 150000 => 150000
memcached.sess_locking => 1 => 1
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_prefix => memc.sess.key. => memc.sess.key.
memcached.sess_randomize_replica_read => 0 => 0
memcached.sess_remove_failed => 0 => 0
memcached.sess_sasl_password => no value => no value
memcached.sess_sasl_username => no value => no value
memcached.store_retry_count => 2 => 2
memcached.use_sasl => 0 => 0
Registered save handlers => files user memcache memcached

So the effective settings file is /etc/php/7.2/cli/conf.d/20-memcached.ini. If you run just :

Vim
1
php -i

You’ll receive information about memcache and memcached.

How To Install Memcached on Ubuntu Server And Configure WordPress

How to configure WordPress with memcached has been discussed in the article WordPress High Load Average With W3 Total Cache.

If you are not using W3 Total Cache, you just need to install WordPress plugin like Memcached Redux, instead of activating it, copy the object-cache.php from plugin directory to wp-content directory.

Tagged With wordpress memcached ubuntu
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How To Install Memcached on Ubuntu Server And Configure WordPress

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • How To Install APC on PHP 7.2 (Ubuntu LAMP Server)

    APC is an Important Part For WordPress Like Web Software to Speed Up. Here is How To Install, Configure APC on PHP 7.2 on Ubuntu LAMP Server.

  • How to Install WordPress : Ubuntu 16.04, Nginx, PHP7-FPM

    Here is Step by Step Guide on How to Install WordPress on Ubuntu 16.04, Nginx, PHP7-FPM, memcached & Percona MySQL 5.7 on Cloud Server or VPS.

  • Optimize php ini for Rackspace Cloud Server (PVHVM)

    Here is a quick guide to optimize php ini for Rackspace Cloud Server (PVHVM) for higher performance and lower page loading speed.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy