Table of Contents
Configure eAccelerator and XCache extensions to accelerate the execution of PHP programs,
Articles you may be interested in:
Home Backend Development PHP Tutorial 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, _PHP Tutorial

Jul 12, 2016 am 09:02 AM
eaccelerator php xcache

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
Copy after login

Found the following:

if (PG(open_basedir) && php_check_open_basedir(realname TSRMLS_CC)) {
Copy after login

changed to

if (PG(open_basedir) && php_check_open_basedir(file_handle->filename TSRMLS_CC)) {
Copy after login

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/
Copy after login

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
Copy after login

will

extension_dir = ./
Copy after login
Replace

with

extension_dir=/usr/local/php-5.2.14/lib/php/extensions/no-debug-non-zts-20060613/
Copy after login

Add eacclerator extension

# vi /usr/local/php-5.2.14/etc/php.ini
Copy after login

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″
Copy after login

Create eaccelerator directory

# mkdir /tmp /eaccelerator
# chmod 777 /tmp/eaccelerator
Copy after login

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″

Copy after login
The amount of shared memory that eAccelerator can use (in megabytes). "0" refers to the default value of the operating system. The default value is "0". It can be adjusted according to the actual situation of the server, 8, 16, 32, 64, 128 is fine.
eaccelerator.cache_dir=”/tmp/eaccelerator ”
Copy after login

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″
Copy after login

Turn eAccelerator on or off. "1" means on, "0" means off. The default value is "1".

eaccelerator.optimizer=”1″
Copy after login

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″
Copy after login

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″
Copy after login

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=””
Copy after login

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″
Copy after login

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″
Copy after login

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″
Copy after login

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″
Copy after login

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″
Copy after login

Allow or disable caching of compressed content. The default value is "1", which means compression is allowed.

eaccelerator.compress_level=”9″
Copy after login

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”
Copy after login

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
Copy after login

It will generate information similar to the following

Installing shared extensions:  /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
Copy after login

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
Copy after login

Reload PHP

# service php-fpm reload
Copy after login

If you are in Apache PHP mode, just restart Apache.

# service httpd restart
Copy after login

or

# /usr/local/apache-2.2.27/bin/apachectl restart
Copy after login

Test results

20151222144250527.png (603×475)

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1084565.htmlTechArticleConfigure eAccelerator and XCache extensions to accelerate the execution of PHP programs, eaccelerator installation and configuration PHP acceleration eAccelerator introduction eAccelerator is a free , open source PHP module, which can...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

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

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

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

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

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

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

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

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

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

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

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

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

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

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

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

See all articles