Lamp platform Installation XCache and memcached to speed up Web site operation

Source: Internet
Author: User
Tags install php ini memcached zip

in the CentOS 7 system to build a good lamp environment, you can install the Web site program, to the most popular wordpess as an example. In order to speed up access to the site, in addition to spending money to buy better hardware facilities. We can optimize the website by program, subject. Turn on caching for the server to speed up the site. We know that the Internet is cached for the king.

1. Install PHP accelerator XCache

XCache is a fast and stable PHP opcode cache that is developed by a Chinese citizen to reduce server load by sharing compiled memory.

Because the Yum source warehouse does not have, first downloads the source file, the newest edition 3.2.0

Under TMP directory: cd/tmp download: wget

Decompression: Tar xvfz xcache-3.2.0.tar.gz

Ready to install: CD xcache-3.2.0

Before installing, prepare the compilation environment: yum-y Install php-devel gcc

Running phpize, very important: phpize


Installation: Make && make install

Replication profile CP xcache.ini/etc/php.d (Xcache.ini in source program installation directory)

Restart the HTTP service: Systemctl restart httpd

2. Install memcached

Memcached is a high-performance distributed memory object caching system for dynamic Web applications to reduce database load. It reduces the number of read databases by caching data and objects in memory, providing the speed of dynamic, database-driven Web sites.

A. Installation

Yum-y Install memcached

Install memcache associated PHP

Yum-y Install Php-pecl-memcache

Compile and install PHP memcache extensions

Download wget

Tar XF memcache-3.0.8.tgz

CD memcache-3.0.8

Execute sequentially



Make && make install

B. Configuration

Add a memcache extension to the php.ini file

Extension=/usr/lib64/php/modules/ (different versions of the catalog may be different)

C. Run

Memcached-d-M 128-c 1024-p/tmp/

D. Testing

Test memcached is working properly, edit a file in the site directory such as Memtest.php, put the following code:

$memcache = new Memcache;

$memcache->connect (' localhost ', 11211) or die ("could not Connect");

$version = $memcache->getversion ();

echo "Server" version: ". $version."

n ";

$tmp _object = new StdClass;

$tmp _object->str_attr = ' Test ';

$tmp _object->int_attr = 123;

$memcache->set (' key ', $tmp _object, False, All) or Die ("Failed to save data at the server");

echo "Store data in the cache" (data would expire in seconds)

n ";

$get _result = $memcache->get (' key ');

echo "Data from the cache:

n ";

Var_dump ($get _result);


After the visit, if you can realistically version number server ' s version:1.4 ... store date in the cache, and other information that memcached is running normally.

5. Integration

WordPress Support Memcached

Download: wget


CD memcached.2.0.2

Copy object-cache.php to the site root wp-content folder, WordPress automatically invokes the cache.

Reboot server:

Sytemctl Restart memcached

Sytemctl Restart httpd

3. Turn on gzip compression.

apache2.4 version of the default added gzip module, we have to open the Deflate module, compressed Web files, improve server browsing speed.

Vim/etc/httpd/conf/httpd.conf at the end add the following lines:

Deflatecompressionlevel 9

Addoutputfilterbytype DEFLATE text/html text/plain text/xml application/x-httpd-php

Addoutputfilter DEFLATE CSS JS

Restart the HTTP service: Systemctl restart httpd

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.