Install Memcached and PHP Memcached extension under CentOS

Install Memcached and PHP Memcached extension under CentOS

Regarding the high-performance distributed memory object caching system Memcached, we have mentioned in another article "How to install memcached in Windows system". This time, let's take a look at how to install Memcached and PHP Memcached extension in CentOS system

I. Install Memcached

1. Install the dependency package libevent

Memcached depends on the libevent library, so you may need to execute before installation

yum install libevent-devel

2. Install memcached

Download the latest source code from http://memcached.org/ (1.4.23)

tar -xzvf memcached-1.4.23.tar.gz 
cd memcached-1.4.23 
./configure --prefix=/usr/local/memcache 
make && make install

3. Configure memcached to start automatically

Copy scripts/memcached.sysv in the source directory to /etc/init.d/memcached. You need to modify the following line in /etc/init.d/memcached:

chown $USER /usr/local/memcache/bin/memcached 
daemon /usr/local/memcache/bin/memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached.pid $OPTIONS

(That is, to modify the path where memcached is located)

Then execute the following command:

chmod 755 memcached 
chkconfig --add memcached

Use the following command to start the service

service memcached start

II. Install PHP Memcached extension

There are two memcache extensions from pecl.php.net:

  • memcache memcached extension
  • memcached PHP extension for interfacing with memcached via libmemcached library

The version of memcached is relatively new and uses the libmemcached library. libmemcached is considered to be better optimized and should have higher performance than the PHP-only version of memcache. So memcached is installed here (assuming php5.4 is already installed in /usr/local/php).

1. Install dependent libraries

https://launchpad.net/libmemcached/1.0/1.0.4/+download/libmemcached-1.0.4.tar.gz

tar -xzvf libmemcached-1.0.4.tar.gz 
cd libmemcached-1.0.4 
./configure 
make 
make install

2. Install memcached

Download from http://pecl.php.net/get/memcached-2.0.1.tgz and install using the following command:

tar vxzf memcached-2.0.1.tgz 
cd memcache-2.0.1 
phpize 
./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config 
make 
make install

After the installation is complete, find the generated memcached.so in the directory indicated by the last displayed Installing shared extensions: /usr/local/*** , and copy it to the directory pointed to by extension_dir in php.ini. Modify php.ini and add the line extension = memcached.so and restart Apache. Then open the phpinfo information page to see if the memcached extension is installed successfully.

Of course, we can also write a small test code to see if memcached is running properly. For specific steps, please refer to the article How to install memcached under Windows system

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • SpringBoot integrates Memcached method example
  • Installation of Memcached server and client under Linux and PHP usage examples
  • Detailed method of installing and deploying Memcached server in CentOS 7.x
  • PHP+Memcached to implement a simple message board function example
  • Basic operations for installing memcached on a Linux server
  • How to configure and use memcached cache in Yii
  • Detailed explanation of the Memcached plugin in the InnoDB engine under MySQL
  • Python memcached startup script code example

<<:  Vue Virtual DOM Quick Start

>>:  MySQL uses find_in_set() function to implement where in() order sorting

Recommend

Detailed explanation of MYSQL stored procedure comments

Table of contents 1. Instructions for use 2. Prep...

How to install MySQL server community version MySQL 5.7.22 winx64 in win10

Download: http://dev.mysql.com/downloads/mysql/ U...

MySQL date processing function example analysis

This article mainly introduces the example analys...

A universal nginx interface to implement reverse proxy configuration

1. What is a proxy server? Proxy server, when the...

Detailed explanation of simple html and css usage

I will use three days to complete the static page...

How to configure NAS on Windows Server 2019

Preface This tutorial installs the latest version...

How to quickly clean up billions of data in MySQL database

Today I received a disk alarm exception. The 50G ...

MySQL 5.7 zip archive version installation tutorial

This article shares the installation tutorial of ...

Mysql Chinese sorting rules description

When using MySQL, we often sort and query a field...

The whole process of node.js using express to automatically build the project

1. Install the express library and generator Open...

Some common mistakes with MySQL null

According to null-values, the value of null in My...

Does the website's text still need to be designed?

Many people may ask, does the text on the website...

An article to understand the use of proxies in JavaScript

Table of contents What is an agent Basic knowledg...