Install XCache to accelerate php-php Tutorial

Source: Internet
Author: User
The installation of XCache is an interpreted language for php acceleration. during The php program running process, the PHP interpreter must be used to explain the process. The interpreter must go through the interpretation-execution steps. this method of interpreting and executing edges is slow. the emergence of the zend Engine changed the php-side interpretation-side execution method to the pre-compilation method, greatly improving the execution efficiency of php in the work.

The zend engine is actually a php interpreter. when a user accesses the php page, the zend Engine first compiles the php source code into the binary format opcode, the file is cached in the memory and then the binary file is executed.

XCache is an opcoude cache. the zend Engine can compile the php source program into opcode. when multiple processes access a source program at the same time, because the process is independent, each process must be compiled once by itself, which leads to repeated compilation. XCache can open up a cache space in the memory and put the opcode compiled by any process in the cache space, the next time a process needs to access the same file, it can directly go to the cache space to retrieve the steps to save compilation. of course, there are a variety of opcode caches like this. at the core of linux2.6, tests show that XCache has good practical experience, and the performance degrades seriously when the number of concurrency increases.

Install XCache as follows:

Environment: CentOs6.4, PHP: php-5.6.8

XCache version: xcache-3.2.0

1. run/usr/local/php/bin/phpize: phpize is an extension tool for php. you must run this command before installing extensions for php.

2. Compile and install

./Configure -- enable-xcache -- with-php-config =/usr/local/php/bin/php-config

Make & make install

3. allow php to support the xcache function

Mkdir/etc/php. d

Cp xcache. ini/etc/php. d/

4. after the installation is complete, restart httpd to call php.info for testing.




Appendix: main parameters of the XCache configuration file

[Xcache-common]
Extension = xcache. so: xcache module name

[Xcache. admin]
Xcache. admin. enable_auth = On: authentication function

Xcache. admin. user = "mOo": authenticated user name
Xcache. admin. pass = "md5 encrypted password": password

[Xcache]
Xcache. shm_scheme = "mmap": how to share memory "mmap" memory ing
Xcache. size = 60 M: cache space size
Xcache. count = 1: set the number of CPUs
Xcache. slots = 8 K: reference value of the number of hash slots xcache. ttl xcache. var_ttl = 0: cache Expiration Time, 0 never expires
Xcache. gc_interval = 0: check the expired items and reclaim the memory space. xcache. var_size = 4 M

Xcache. var_count = 1
Xcache. var_slots = 8 K
Xcache. var_ttl = 0
Xcache. var_maxttl = 0
Xcache. var_gc_interval = 300
Xcache. var_namespace_mode = 0
Xcache. var_namespace = ""
Xcache. readonly_protection = Off
Xcache. mmap_path = "/dev/zero"
Xcache. coredump_directory = ""
Xcache. coredump_type = 0
Xcache. disable_on_crash = Off
Xcache. experimental = Off
Xcache. cacher = On: The xcache function is enabled. it is invalid when the cache space is 0.

Xcache. stat = On: Check for script updates
Xcache. optimizer = Off

[Xcache. coverager]
Xcache. coverager = Off
Xcache. coverager_autostart = On: each page request automatically calls xcache
Xcache. coveragedump_directory = ""

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.