USharing
开放博客

How to Install Memcached on Debian 10/9/8

Memcached is a distributed memory object caching system, which stored data in memory on key-value basis. It is very useful for optimizing dynamic websites and enhanced speed by caching objects in memory. This article will help you to install Memcached with PHP Memcache extension on Debian 10, Debian 9 Stretch and Debian 8 Jessie systems.

tep 1 – Install Memcached on Debian

Update apt package cache on your system and then install Memcached on Debian system. Execute below commands on the terminal in your Debian system.

sudo apt update
sudo apt install memcached

Step 2 – Memcached Configuration

You can find the details information about Memcache configuration here. For inital level configuration check for the following settings under Memcache configuration file /etc/memcached.conf.

  • -d => Run Memcached in deamon mode.
  • -m => Maximum memory to be used by Memcached. (default: 64 MB)
  • -p => Define port for Memcached. (default: 11211)
  • -l => Define IP address to listen on. Use 0.0.0.0 to listen on all IPs(enterfaces).

After making changes, restart the Memcached service.

Step 3 – Test Memcached Setup

Use nc command to check Memcached status. This will show you the current statistics of running Memcached server. So the values may differ per installation.

echo "stats" | nc localhost 11211

STAT maxbytes 67108864
STAT maxconns 1024
STAT tcpport 11211
STAT udpport 0
STAT inter 127.0.0.1
STAT verbosity 0
STAT oldest 0
STAT evictions on
STAT domain_socket NULL
STAT umask 700
STAT growth_factor 1.25
STAT chunk_size 48
STAT num_threads 4
STAT num_threads_per_udp 4
STAT stat_key_prefix :
STAT detail_enabled no
STAT reqs_per_event 20
STAT cas_enabled yes
STAT tcp_backlog 1024
STAT binding_protocol auto-negotiate
STAT auth_enabled_sasl no
STAT item_size_max 1048576
STAT maxconns_fast no
STAT hashpower_init 0
STAT slab_reassign no
STAT slab_automove 0
STAT slab_chunk_max 1048576
STAT lru_crawler no
STAT lru_crawler_sleep 100
STAT lru_crawler_tocrawl 0
STAT tail_repair_time 0
STAT flush_enabled yes
STAT hash_algorithm jenkins
STAT lru_maintainer_thread no
STAT hot_lru_pct 32
STAT warm_lru_pct 32
STAT expirezero_does_not_evict no
STAT idle_timeout 0
STAT watcher_logbuf_size 262144
STAT worker_logbuf_size 65536
STAT track_sizes no
END

Step 4 – Install Memcached PHP Extension

Execute the following command to install PHP Memcached extension on your system.

sudo apt install php-memcached

After completing the installation, you must restart the Apache service to reload all settings.

phpenmod memcached 
sudo service apache2 restart

All done, You can now test Memcache PHP extension is enabled and working properly by creating an info.php file using the following code.

Now copy info.php file on Apache document root and access on the web interface. Search for the Memcache, You will get the result.

赞(0) 打赏
未经允许不得转载:USharing » How to Install Memcached on Debian 10/9/8

觉得文章有用就打赏一下文章作者

微信扫一扫打赏