We know that Eaccelerator is a free open source PHP accelerator, optimized and dynamic content cache, can improve the PHP script cache performance, and to optimize the script, so that your PHP program code execution efficiency can increase 1-10 times, today to teach you PHP optimization cache method.
2. Caching principle
When a user requests a PHP program, the PHP engine parses the program and compiles it into a specific opcode (opcode), which is a binary-formatted executable code. The opcode is then executed and discarded by the PHP engine. The opcode cache saves this compiled opcode and reuses it the next time the page is called, saving a lot of time to repeat the compilation, saving resources, and optimizing performance.
3. Installing Eaccelerator
Adjust Character Set
#echo ' lc_all=c ' >>/etc/profile#source/etc/profile[root@~] #tar jxf eaccelerator-0.9.6.tar.bz2[root@~] #cd Eaccelerator-0.9.6[root@~]#/usr/local/php/bin/phpizephpize is used to extend the PHP module, through the phpize can build PHP plug-in module [root@~]#./configure --enable-eaccelerator=shared \--with-php-config=/usr/local/php-5.3.27/bin/php-config[root@~] #make && make install[root@~]# ls/usr/local/php-5.3.27/lib/php/extensions/no-debug-zts-20090626/eaccelerator.so
4. Configure PHP Load Eaccelerator
Create a cache directory
Mkdir/tmp/eaccelerator #可目录可以用tmpfs内存文件系统来存储, SSD solid-state Drive
Chown-r Www.www/tmp/eaccelerator
In php.ini, add the following:
Eaccelerator Cache config by Zhang dejin 2017-12-1[eaccelerator]extension = eaccelerator.soeaccelerator.shm_size= "64" Eaccelerator.cache_dir= "/tmp/eaccelerator" eaccelerator.enable= "1" eaccelerator.optimizer= "1" eaccelerator.chech_ Mtime= "1" eaccelerator.debug= "0" eaccelerator.filter= "" eaccelerator.shm_max= "0" eaccelerator.shm_ttl= "3600" eaccelerator.shm_prune_perid= "3600" eaccelerator.shm_only= "0" eaccelerator.compress= "1" eaccelerator.compress_ Level= "9"--end config test: [root@lnmp nginx]#/usr/local/php-5.3.27/bin/php-vphp 5.3.27 (CLI) (Built:nov 30 2017 05:35:00) Copyright (c) 1997-2013 the PHP groupzend Engine v2.3.0, Copyright (c) 1998-2013 Zend technologieswith eaccelerator v0.9.6 , Copyright (c) 2004-2010 eaccelerator, by Eaccelerat
Configuration complete
Restart httpd or php-fpm in effect
5. Version Selection
PHP5.3.XX Available eaccelerator-0.9.6 version
PHP5.2.XX Available eaccelerator-0.9.5.2 version
2) Xcache
1 Introduction
XCache is a fast and stable PHP opcode cache. Good testing and stable operation on large-flow/high-load production machines. Tested and supported on (on Linux) the latest release versions of all current PHP branches, such as Php_4_3 php_4_4 php_5_0 php_5_1 php_5_2 HEAD (6.x), and support for thread safety/windows. Better than a similar opcode cache, such as the ability to quickly follow up on PHP versions. XCache Project by MOo leader, he is also one of the development members of LIGHTTPD. LIGHTTPD is one of the fastest Web server applications and goes beyond Apache and many other Web servers. XCache efforts to achieve a similar effect. 2. Installation
Tar jxf xcache-1.3.2.tar.bz2cd xcache-1.3.2/usr/local/php-5.3.27/bin/phpize./configure--enable-xcache-- With-php-config=/usr/local/php-5.3.27/bin/php-configmake && make installls/usr/local/php-5.3.27/lib/php/ extensions/no-debug-zts-20090626/
3. Configure PHP Load XCache
cd/usr/local/php/lib/
Add notes
echo >> php.iniecho "XCache config by Zhangdejin 2017-12-1"
Modify Xcache-1.3.2/xcache.ini, use sed command to modify
Note Third line
Zend_extension =/usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so
Note Line Sixth
Zend_extension_ts = C:/php/extensions/php_xcache.dll
Enable line Eighth
; extension = xcache.so
The remaining parameters are self-tuning based on the server configuration
Then join the php.ini
Cat/home/king/xcache-1.3.2/xcache.ini >> php.ini
Test
/usr/local/php-5.3.27/bin/php-vphp 5.3.27 (CLI) (Built:nov 18:03:24) Copyright (c) 1997-2013 the PHP groupzend En Gine v2.3.0, Copyright (c) 1998-2013 Zend technologieswith XCache v1.3.2, Copyright (c) 2005-2011, by MOo
Restart httpd or php-fpm in effect
3) Memcache client, Pdo_mysql,imagick Extension Library
1. Introduction
Memcache is a high-performance distributed memory object caching system that maintains a unified, huge hash table in memory that can be used to store data in various formats, including images, video files, and database retrieval results, simply by calling data into memory and then reading from memory. Thus greatly improving the reading speed
The PDO extension defines a lightweight, consistent interface for the PHP Access database, which provides a data access abstraction layer so that data can be obtained through a consistent function execution query, regardless of the database used
ImageMagick is a powerful, stable and free working set and development package, with images over 89 formats in the format of resizing, rotating, sharpening, subtractive processing, and now its main focus on performance, reducing bugs as well as providing stable APIs and Abi on
2. Installation
Tar zxf memcache-2.2.5.tgzcd memcache-2.2.5/usr/local/php-5.3.27/bin/phpize./configure--with-php-config=/usr/ Local/php-5.3.27/bin/php-configmake && make installln/usr/local/php-5.3.27/lib/php/extensions/ no-debug-zts-20090626/ls/usr/local/php-5.3.27/lib/php/extensions/no-debug-zts-20090626/Installing Pdo_mysqltar zxf PDO_ MYSQL-1.0.2.TGZCD pdo_mysql-1.0.2/usr/local/php-5.3.27/bin/phpize./configure--with-php-config=/usr/local/ Php-5.3.27/bin/php-config--with-pdo-mysql=/usr/local/mysql/make && Make installls/usr/local/php-5.3.27/ Lib/php/extensions/no-debug-non-zts-2009062yum Install Perl-devel-ytar zxf ImageMagick.tar.gzcd imagemagick-6.5.1-2 /./configuremake && make install Imagicktar zxf imagick-2.3.0.tgzcd imagick-2.3.0/usr/local/php-5.3.27/bin/ Phpize./configure--with-php-config=/usr/local/php-5.3.27/bin/php-configmake && Make installls/usr/local/ php-5.3.27/lib/php/extensions/no-debug-zts-20090626/configuration PHP loading Pdo_mysql,memcache,imagick modules such as modify Extension_dir = "./" forExtension_dir = "/usr/local/php-5.3.27/lib/php/extensions/no-debug-zts-20090626/" add these modules;--cache ext start by Zhang Dejin 2017-12-1extension = memcache.soextension = Pdo_mysql.soextension = imagick.so; End Config:
View Nginx Compilation parameters
Nginx-v
View httpd Compilation parameters
Cat Httpd/build/config.nice
View MySQL Compilation parameters
grep "Configure_line" Mysql/bin/mysqlbug
PHP Compilation parameters
Php/bin/php-i|grep Configure
Complete
Believe that you have seen these cases you have mastered the method, more wonderful please pay attention to the PHP Chinese network other related articles!
Related reading:
The problem solution of hump naming and JS
A detailed description of Boolean, relational, and logical operators in JS and examples
Summary of the JS framework of the front end and usage explanation