XCache Accelerating PHP Cache notes

Source: Internet
Author: User
Tags zts

PHP Cache and Optimization combat

Caching principle:

When the user requests a PHP program, the server's PHP engine to parse PHP according to the client request, and compile the code as a specific operation code, by default, PHP after parsing will automatically discard the parsed opcode, and the opcode cache will be the user request to parse the source code into the shared memory, Convenient next tune-up, which greatly reduces the load on the CPU

LNMP PHP Caching process

1 First the client requests a PHP request to the server

2 after the server receives the client request, this information will be given to the PHP engine, that is, fastcgi (PHP-FPM) for processing, lamp with the Apache plug-in (LIBSO).

3PHP-FPM call PHP parser to read PHP file of site disk, load into memory

The 4php parser compiles the PHP program into a opcode file and caches it.

The 5php program returns the OPCPDE to Nginx after execution, and then returns to the client

6nginx accept the client request again, will be directly from the opcode, so there is no need to perform 4th, convenient and concise

PHP Cache Accelerator:

Common Xcache,eaccelerator,zendopcache, commonly used in enterprises or XCache, followed by Eaccelerator.

Then start installing cache acceleration Software Now

Environment Preparation:

According to my previous LNMP environment to build, there is a need to look at the document.

View Nginx Web version

[Email protected] ~]#/application/nginx/sbin/nginx-v

Nginx version:nginx/1.6.2

PHP version

[Email protected] ~]#/application/php/bin/php-v

PHP 5.3.28 (CLI) (BUILT:APR 16 2016 03:56:50)

Copyright (c) 1997-2013 the PHP Group

Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

MySQL version

[Email protected] ~]# mysql-u root-p

Enter Password:

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 1

Server version:5.5.32 MySQL Community Server (GPL)

LNMP Cache Hint:

Whether it is Apache or Nginx, the last is to provide a dynamic parser through PHP, Whether it is the Apache libphp5.so module mode, or Nginx fastcgi mode, are the same, PHP engine optimization is consistent, are based on PHP services (php.ini) to do, there is no difference between the two!

Installing the PHP Cache accelerator

So I'm here to use the XCache cache software directly.

First download XCache

[email protected] xiaohu]# wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.bz2

[Email protected] xcache-3.2.0]#/configure--enable-xcache--with-php-config=/application/php/bin/php-config

[[email protected] xcache-3.2.0]# make

Don ' t forget to run ' make test '. This success, continue the Install

[[email protected] xcache-3.2.0]# make install

Installing Shared extensions:/application/php/lib/php/extensions/no-debug-non-zts-20090626/

See if there are any xcache.so files that represent success

[Email protected] xcache-3.2.0]# ls-l/application/php/lib/php/extensions/no-debug-non-zts-20090626/xcache.so

-rwxr-xr-x. 1 root root 653772 April 22:14/application/php/lib/php/extensions/no-debug-non-zts-20090626/xcache.so

Verify XCache

Modify the php.ini configuration XCache

[Email protected] ~]# cd/application/php/lib/

[[email protected] lib]# ls

PHP php.ini

[Email protected] lib]# echo >>php.ini

[[email protected] lib]# echo '; xcache config by Xiaohu 20160419--------------' >> php.ini

[Email protected] lib]# Tail-2 php.ini

; xcache config by Xiaohu 20160419--------------

Edit Xcache.ini Modify related configuration parameters

[Email protected] ~]# vim Xiaohu/xcache-3.2.0/xcache.ini

Load the modified XCache into the php.ini

[email protected] ~]# cat Xiaohu/xcache-3.2.0/xcache.ini >>/application/php/lib/php.ini

View modified parameters, modify only relevant parameters

Check XCache cache acceleration Status

Execute the PHP command again to see if the cache is in effect


XCache Accelerating PHP Cache notes

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.