PHP defaults to discard the operate code file, cache acceleration is saved, placed in shared memory, to be reused the next time the PHP page is invoked, to avoid duplicate compilation of the same Code
___________________________________________________________
Lamp Environment PHP Parsing principle
___________________________________________________________
Apache receives the client's PHP program request and filters it according to the rules
Apache passes the PHP program request to the PHP processing module libphp5.so
The PHP engine locates the PHP file on the disk and loads it into memory for parsing
PHP processing module libphp5.so PHP source code compiled into opcode
The PHP processing module libphp5.so executes opcode and then caches the opcode.
Apache receives a new PHP program request from the client, the PHP engine reads the cache directly to execute the opcode file, and returns the result
LNMP Environment PHP Parsing principle
___________________________________________________________
Nginx receives the client's PHP program Access request
Nginx passes PHP program requests to the FCGI (PHP FPM) process that parses PHP based on filtering rules such as extensions
PHP fpm Process calls PHP parser to read PHP file on site disk and load into memory
The PHP parser compiles the PHP program into a opcode file and then caches the opcode.
PHP fpm engine executes opcode tree, returns data to Nginx, and returns to client
Nginx receives a new PHP program request from the client, the PHP fpm engine reads the opcode in the cache and executes it, returning the result
Cache acceleration Plug-in installation configuration (XCache)
___________________________________________________________
[Root@Web_server src]# wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.bz2
[Root@Web_server src]# tar XF xcache-3.2.0.tar.bz2
[Root@Web_server src]# cd xcache-3.2.0
[Root@Web_server xcache-3. 2. 0]#/usr/local/php/bin/phpize
[Root@Web_server xcache-3. 2. 0]
[Root@Web_server xcache-3. 2. 0]# make && make install
[Root@Web_server xcache-3. 2. 0]# ll/usr/local/php/lib/php/extensions/ no-debug-non-zts-20121212/
2208
-RWXR-xr:opcache. A
-RWXR-xr1 root root :opcache. so
-RWXR-xr1 root :xcache#<== generate xcache.so module
[Root@Web_server xcache-3. 2. 0]# Cat/usr/local/src/xcache-3.2.0/xcache.ini >>/ Usr/local/php/etc/php.ini
[Root@Web_server xcache-3. 2. 0]# Tail-85/usr/local/php/etc/php.ini | egrep-v "^;|^$"
[XCache-common]
= XCache. so
[XCache. Admin]
XCache. Admin= on
XCache. Admin"MOo"
XCache. Admin"MD5 encrypted password"
[XCache]
XCache= "mmap"
XCache. Size = 256M
XCache. = 2
XCache= 8K
XCache. TTL = 86400
XCache= 3600
XCache. var_size = 64M
#更改标红参数, the production environment adjusts to hardware and business data
[Root@Web_server xcache-3. 2. 0]#/usr/local/php/bin/php-v #检查配置
PHP 5. 5(CLI(built: +)
(c1997-ThePHP Group
Zend Engine v2. 5. 0(C1998-Zend Technologies
With XCache v3. 2. 0(C2005-up, by MOo
With XCache Cacher v3. 2. 0(C2005-up, by MOo
[Root@Web_server ~]# echo-n "Szk" |md5sum
[Root@Web_server ~]# vim/usr/local/php/etc/php.ini #配置xcache用户密码
XCache. Admin"Szk"
XCache. Admin"005EFF7DD9626F0C30F2EB8003CEAFC9"
[Root@Web_server ~]# cp-a/usr/local/src/xcache-3.2.0/htdocs//data/www/xadmin
[Root@Web_server ~]# chown-r nobody.nobody/data/www/xadmin
[Root@Web_server ~]#/etc/init.d/php-fpm start
Cache acceleration Plug-in installation configuration (Opcache)
___________________________________________________________
#若5. Version 5, the Opcache plugin is automatically installed and--enable=opcache enabled at compile time
[Root@Web_server ~]# ll/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
-RWXR-xr1 root root :opcache. so
[Root@Web_server ~]# Vim/usr/local/php/etc/php.ini #若编译没有启用, add the following to the configuration file
Zend_extension=opcache. So
[Opcache]
Opcache. memory_consumption=
Opcache. Interned_strings_buffer=8
Opcache. Max_accelerated_files=4000
Opcache. Revalidate_freq=
Opcache. Fast_shutdown=1
Opcache. Enable=1
Opcache. Enable_cli=1
[Root@Web_server ~]#/usr/local/php/bin/php-v
PHP 5. 5(CLI(built :
(c1997-ThePHP Group
Zend Engine v2. 5. 0(C1998-Zend Technologies
With Zend Opcache V7. 0. 6-dev(C1999-$, by Zend Technologies
PHP Enable cache acceleration