


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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











PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.
