search
HomeBackend DevelopmentPHP TutorialConfigure 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 = ./
Replace

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″

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 ”

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

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
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
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

See all articles

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

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.