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 http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz

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

Configuration:./configure--enable-xcache

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 http://pecl.php.net/get/memcache-3.0.8.tgz

Tar XF memcache-3.0.8.tgz

CD memcache-3.0.8

Execute sequentially

Phpize

./configure

Make && make install

B. Configuration

Add a memcache extension to the php.ini file

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

C. Run

Memcached-d-M 128-c 1024-p/tmp/memcached.pid

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 https://downloads.wordpress.org/plugin/memcached.2.0.2.zip

Unzip Memcached.2.0.2.zip

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

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.