


Configure eAccelerator and XCache extensions to accelerate the execution of PHP programs, _PHP Tutorial
Configure eAccelerator and XCache extensions to accelerate the execution of PHP programs,
eaccelerator installation and configuration PHP acceleration
Introduction to eAccelerator
eAccelerator is a free, open source PHP module that provides PHP acceleration, optimization, encoding, and dynamic content caching functions. It speeds up the execution of PHP scripts by storing the compiled state of the PHP script without the need to compile the PHP script frequently. And it can optimize PHP scripts to increase the speed of executing PHP. The feature of eAccelerator is that it reduces the server load and accelerates PHP scripts by 1-10 times.
Download address: http://sourceforge.net/projects/eaccelerator/
Unzip and modify the source code (solve errors such as open_basedir)
# tar jxvf eaccelerator-0.9.6.tar.bz2 # cd eaccelerator-0.9.6/ # vi eaccelerator.c
Found the following:
if (PG(open_basedir) && php_check_open_basedir(realname TSRMLS_CC)) {
changed to
if (PG(open_basedir) && php_check_open_basedir(file_handle->filename TSRMLS_CC)) {
Compile and install the extension eaccelerator
# /usr/local/php-5.2.14/bin/phpize # 对应你自己的phpize,一定要在eaccelerator-0.9.6目录执行 # ./configure –enable-eaccelerator \ –with-php-config=/usr/local/php-5.2.14/bin/php-config # make # make install # 会提示你扩展装到了哪个目录,我这边是/usr/local/php-5.2.14/lib/php/extensions/no-debug-non-zts-20060613/
Configure php.ini
If an extension has been added to this machine before, jump directly to the next step "Add eacclerator extension"
Vi /usr/local/php-5.2.14/etc/php.ini
will
extension_dir = ./
with
extension_dir=/usr/local/php-5.2.14/lib/php/extensions/no-debug-non-zts-20060613/
Add eacclerator extension
# vi /usr/local/php-5.2.14/etc/php.ini
Add the following content
[eaccelerator] extension=eaccelerator.so eaccelerator.shm_size=”16″ eaccelerator.cache_dir=”/tmp/eaccelerator” eaccelerator.enable=”1″ eaccelerator.optimizer=”1″ eaccelerator.check_mtime=”1″ eaccelerator.debug=”0″ eaccelerator.filter=”” eaccelerator.shm_max=”0″ eaccelerator.shm_ttl=”0″ eaccelerator.shm_prune_period=”0″ eaccelerator.shm_only=”0″ eaccelerator.compress=”1″ eaccelerator.compress_level=”9″
Create eaccelerator directory
# mkdir /tmp /eaccelerator # chmod 777 /tmp/eaccelerator
Restart testing
Restart apache or nginx and check the effect. If there is a directory under /tmp/eaccelerator, the installation is successful.
Detailed explanation of configuration parameters (eaccelerator)
eaccelerator.shm_size=”8″
eaccelerator.cache_dir=”/tmp/eaccelerator ”
This directory is used for disk caching. eAccelerator stores precompiled code, process data, content and user-defined content here. The same data can also be stored in shared memory (this can improve access speed) . The default setting is "/tmp/eaccelerator".
eaccelerator.enable=”1″
Turn eAccelerator on or off. "1" means on, "0" means off. The default value is "1".
eaccelerator.optimizer=”1″
Enable or disable the internal optimizer to improve code execution speed. "1" means on, "0" means off. The default value is "1".
eaccelerator.check_mtime=”1″
Turn on or off PHP's file modification check. "1" means on, "0" means off. If you recompile PHP files after modification, then you should set it to "1". The default value is " 1”.
eaccelerator.debug=”0″
Turn debug logging on or off. "1" means on, "0" means off. The default value is "0". Records of cache hits will be written to the log.
eaccelerator.filter=””
Determine which PHP files must be cached. You can specify cached and non-cacheable file types (such as "*.php *.phtml", etc.). If the parameters start with "!", files matching these parameters will be ignored from the cache. The default value is "", i.e. all PHP files will be cached.
eaccelerator.shm_max=”0″
When using the "eaccelerator_put()" function, it is prohibited to store files that are too large into shared memory. This parameter specifies the maximum value allowed to be stored, in bytes (10240, 10K, 1M). "0" means no limit. The default value is "0".
eaccelerator.shm_ttl=”0″
When eAccelerator fails to obtain the shared memory size for a new script, it will delete all script caches from shared memory that have not been accessed in the last "shm_ttl" seconds. The default value is "0", which means no cache files are deleted from the share.
eaccelerator.shm_prune_period=”0″
When eAccelerator fails to obtain the shared memory size for a new script, it will attempt to remove cached scripts older than "shm_prune_period" seconds from shared memory. The default value is "0", which means no cache files are deleted from the share.
eaccelerator.shm_only=”0″
Allow or disable caching of compiled scripts on disk. This option has no effect on session data and content caching. The default value is "0", which means: use disk and shared memory for caching.
eaccelerator.compress=”1″
Allow or disable caching of compressed content. The default value is "1", which means compression is allowed.
eaccelerator.compress_level=”9″
Specify the compression level for content caching. The default value is "9", the highest level.
eaccelerator.keys = “disk_only” eaccelerator.session = “disk_only” eaccelerator.content = “disk_only”
Set the storage location of the content cache, which can be set to:
- shm_and_disk on shared cache and disk (default)
- shm exists in shared memory by default. If the shared memory is full or the size exceeds the value of "eaccelerator.shm_max", it will be saved to the hard disk
- shm_only is only stored in shared memory
- disk_only only stored in hard disk
- none does not cache data
PHP extension xcache installation
The xcache module can cache the opcode generated by PHP runtime compilation, which can speed up the efficiency of PHP programs. The method of installing xcache is similar to that of installing memcache. They are both installed in an extended manner. Any extension method for PHP is basically as follows, so no need I specifically looked for the documentation for the xxx extension.
Install PHP extension xcache
# wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz # tar -xvf xcache-3.2.0.tar.gz # cd xcache-3.2.0 # ./configure –with-php-config=/usr/local/php/bin/php-config –enable-xcache # make && make install
It will generate information similar to the following
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
All modules will be generated in this directory
Edit php configuration file
# vim /usr/local/php/etc/php.ini extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xcache.so
Reload PHP
# service php-fpm reload
If you are in Apache PHP mode, just restart Apache.
# service httpd restart
or
# /usr/local/apache-2.2.27/bin/apachectl restart
Test results
Articles you may be interested in:
- Notes on installing PHP xcache extension module under CentOS 6.3
- Specific steps for compiling and installing xcache for php5.3 under ubuntu
- PHP Accelerator eAccelerator Configuration and Usage Guide

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
