XCache speed up for PHP

Source: Internet
Author: User
Tags zts

XCache is a fast and stable PHP opcode cache. Good testing and stable operation on large-flow/high-load production machines. After testing (on Linux) and supporting the latest release versions of all current PHP branches, such as Php_5_1 php_5_2 Php_5_3 Php_5_4. and perfectly supports thread-safe/windows. Better than a similar opcode cache, such as the ability to quickly follow up on PHP versions.

For more details, please visit XCache official website:http://xcache.lighttpd.net/

Installation steps:

1, decompression tar.gz bag

[[email protected] ~]# tar xf xcache-3.0.4.tar.gz  -c /usr/local/src[[ email protected] ~]# cd /usr/local/src[[email protected] src]# cd  xcache-3.0.4/###  viewing the installation steps [[Email protected] xcache-3.0.4]# vim installinstalltion:     $ phpize --clean && phpize    $ . /configure --help    $ cflags= ' Your cflags '  ./configure -- enable-xcache --enable...    $ make    $ su     # make install         (Update php.ini,  restart php)          ###  Use the local interpreter to probe the version number/extension API on which the module depends , generate the serial number token, and then generate the Configure file before compiling [[email protected] xcache-3.0.4]# /usr/local/php/bin/phpize  [[email protected] xcache-3.0.4]# ./configure --enable-xcache --enable-xcache-coverager -- enable-xcache-optimizer --with-php-config=/usr/local/php/bin/php-config#  Note:--enable-xcache             #  Enable Xcache--enable-xcache-vocerager   #  additional features--enable-xcache-optimizer  #  enable opcode optimization [[email protected]  xcache-3.0.4]# make && make install##  the path to the xcache.so module is prompted after the installation is complete,  We moved the xcache.so to the/usr/local/php/include/php/ext directory for easy Management installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20100525/[[email protected] xcache-3.0.4]#  mv /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so  /usr/local/php/ include/php/ext/##  generate XCache Administrator's password (MD5 ciphertext) [[email protected] ~]# echo -n  ' 123456 '  | md5sume10adc3949ba59abbe56e057f20f883e

2, Consolidated PHP and XCache

[[email protected] xcache-3.0.4]# cp xcache.ini /etc/php.d/###  Edit xcache.ini## Typically only edit Extension = xcache.admin.enable_auth =xcache.admin.user = xcache.admin.pass  =#####################################[xcache-common]extension =  "/usr/local/php/include/php/ Ext/xcache.so "; xcache.so path [xcache.admin]xcache.admin.enable_auth = on; turn on validation xcache.admin.user =   "XCache"; Verify name xcache.admin.pass =  "E10ADC3949BA59ABBE56E057F20F883E"; MD5 authentication password,  that is echo  -n  "123456"  | md5sum, leave the Administration page blank. [xcache]xcache.shm_scheme = "Mmap";  decide  XCache  How to allocate shared memory from the system xcache.size=60m; 0  forbidden,   Non- 0  enable cache .  Please note that the  mmap  maximum value that your system allows .xcache.count =1;  specifies that the  cache  Cut into how many pieces. (Cat/proc/cpuinfo |grep -c processor) xcache.slots =8k;  only as a reference value for the number of  hash  slots,   You can safely buffer more than this number of items .xcache.ttl=0;  set the buffer item  Ttl  (TIME TO&NBSp Live)   Value,  0= never expires .xcache.gc_interval =0;  check for expired items,  the interval to reclaim memory space. Xcache.var_size=4mxcache.var _count =1xcache.var_slots =8k;  Ibid,  but for data buffering instead of  opcode  buffering .xcache.var_ttl=0;  Xcache_ (GET|SET|INC|DEC)   default  ttl  value .xcache.var_maxttl=0;  Max  ttl  value,  The program cannot specify a  ttl.xcache.var_gc_interval =300xcache.test =offxcache.readonly_protection = that exceeds this maximum value  On; If enabled  ReadonlyProtection,  will slightly degrade performance,  but will increase a certain factor of safety .  this option for xcache.mmap_path =  /dev/zero  invalid. xcache.mmap_path = "/tmp/xcache"; cache files, not directories, need to be created manually xcache.coredump_directory = " "xcache.cacher =on; is not valid when using/not using  opcode  cache . xcache.size = 0 . Xcache.stat=on; use  stat ()   Discovery Check script update .xcache.optimizer =off[xcache.coverager]xcache.coverager =on; enable code overlay information to capture.   Enable xcache.coveragedump_directory  settings and Xcache_coverager_start/stop/get/clean ()   to use .  ( When enabled will affect the decrease) xcache.coverager_autostart = on; each page request is automatically called  xcache_coverager_startxcache.coveragedump_directory = "" 



3. Generate XCache Cache file

[Email protected] ~]# touch/tmp/xcache[[email protected] ~]# chmod 777/tmp/xcache


4. Manage with admin

In fact, to be a site, there are 5 ways to access:

(Physical directory, virtual directory, IP based, port based, host based)

#  Copy the XCache hypervisor to the Web site root [[email protected] xcache-3.0.4]# cp -a htdocs /usr/ local/apache/htdocs/xadmin#  Restart  httpd,  Restart the PHP-FPM service if the fastcgi mode is required [[email protected] ~] # service httpd restart[[email protected] ~]# service php-fpm  Restart Error: starting php-fpm: [21-jul-2014 18:55:21] notice: php message: php  Warning:  PHP Startup: Unable to load dynamic library  ' usr /local/php/include/php/ext/xcache.so '  - /usr/local/php/include/php/ext/xcache.so: undefined  symbol: core_globals_id in unknown on line 0#########################   ????????? #  Here I don't know what happens,  don't know if it's a version of the problem # httpd-2.2.27 , php-5.4.30 , xcache-3.0.4  , fastCGI  # #  I hope you will answer ##########################  later, I still use module way,  It's all OK. [[EMAIL&NBsp;protected] ~]# vi /etc/httpd/httpd.confloadmodule php5_module         modules/libphp5.so#LoadModule fastcgi_module         modules/mod_fastcgi.so[[email protected] httpd]# service httpd restart


Then access Http://localhost/xadmin, the user name is XCache, password is 123456;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/41/4E/wKiom1PSLvLjD9UXAALS27M-s-0748.jpg "title=" Cache.png "alt=" Wkiom1pslvljd9uxaals27m-s-0748.jpg "/>


In addition, Phpinfo can also be used to verify whether PHP supports XCache

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/41/4E/wKioL1PSMG3ShSZJAAH_eOqH7gE007.jpg "title=" Cache.png "alt=" Wkiol1psmg3shszjaah_eoqh7ge007.jpg "/>


Reference:

http://51log.blog.51cto.com/6076767/1291006

Http://wushuaishuai.cn/xcache-buffer-introduction-use-and-configure.html


This article is from the "Share Your Knowledge" blog, so be sure to keep this source http://skypegnu1.blog.51cto.com/8991766/1530232

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.