Configure Eaccelerator and XCache extensions to accelerate the execution of PHP programs, _php tutorials

Source: Internet
Author: User

Configure Eaccelerator and XCache extensions to speed up the execution of PHP programs,


Eaccelerator Installation Configuration PHP acceleration
Eaccelerator Introduction
Eaccelerator is a free, open source PHP module that provides PHP acceleration, optimization, overweight, and dynamic content caching capabilities. It speeds up the execution of PHP scripts by storing the compiled state of the PHP script without having to compile the PHP script frequently. And it can optimize PHP scripts to improve the speed of PHP execution. Eaccelerator features reduced server load and accelerated PHP scripting by 1-10 Times.
Download Address: http://sourceforge.net/projects/eaccelerator/
Decompression to modify the source code (to resolve the occurrence of open_basedir and other errors)

# tar jxvf eaccelerator-0.9.6.tar.bz2# cd eaccelerator-0.9.6/# VI eaccelerator.c

Find the following:

if (PG (open_basedir) && php_check_open_basedir (realname tsrmls_cc)) {

Switch

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 # corresponding to your own phpize, be sure to execute # in the eaccelerator-0.9.6 directory./configure–enable-eaccelerator \– with-php-config=/usr/local/php-5.2.14/bin/php-config# make# make install # will prompt you to expand which directory to install, my side is/usr/local/php-5.2.14/ lib/php/extensions/no-debug-non-zts-20060613/

Configure PHP.ini
If this machine has previously been extended, skip directly to the next step "add eacclerator extension"

Vi/usr/local/php-5.2.14/etc/php.ini

Will

Extension_dir =./

Replaced by

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

Adding Eacclerator Extensions

# 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 a eaccelerator directory

# mkdir/tmp/eaccelerator# chmod 777/tmp/eaccelerator

Restart Test
Restart Apache or Nginx, and see the effect, if there is a directory under/tmp/eaccelerator, the installation is successful.
Detailed 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". can be adjusted according to the actual situation of the server, 8,16,32,64,128 are OK.
Eaccelerator.cache_dir= "/tmp/eaccelerator"

This directory is used for disk caching. Eaccelerator stores pre-compiled code, process data, content, and user-defined content here. The same data can also be stored in shared memory (which can improve access speed). The default setting is "/tmp/eaccelerator".

Eaccelerator.enable= "1″

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

Eaccelerator.optimizer= "1″

Power on or off the internal optimizer to increase code execution speed. "1" is on, "0" is off. The default value is "1".

Eaccelerator.check_mtime= "1″

Open or close the PHP file modification check. "1" means open, "0" means close. If you recompile the PHP file after you modify it, you should set it to "1". The default value is "1".

Eaccelerator.debug= "0″

Turn debug logging on or off. "1" is on, "0" is off. The default value is "0". Records are written to the log when the cache is hit.

Eaccelerator.filter= ""

Determine which PHP files must be cached. You can specify the cache and non-cached file types (such as "*.php *.phtml", etc.), and if the arguments start with "!", the files that match those parameters are ignored by the cache. The default value is "", that is, all PHP files will be cached.

eaccelerator.shm_max= "0″

When you use the "eaccelerator_put ()" function, it is forbidden to store too large files in shared memory. This parameter specifies the maximum value that is allowed to be stored in bytes (10240, 10K, 1M). "0" is not limited. The default value is "0".

Eaccelerator.shm_ttl= "0″

When Eaccelerator gets the shared memory size of a new script fails, it removes all script caches that were not accessed in the last "Shm_ttl" seconds from shared memory. The default value is "0", which is: Do not delete any cache files from the share inner spring.

Eaccelerator.shm_prune_period= "0″

When Eaccelerator gets the shared memory size of a new script fails, he tries to remove the cache script that is older than "shm_prune_period" seconds from shared memory. The default value is "0", which is: Do not delete any cache files from the share inner spring.

Eaccelerator.shm_only= "0″

Allows or disables the caching of compiled scripts on disk. This option is not valid for session data and content caching. The default value is "0", which is: Use disk and shared memory for caching.

Eaccelerator.compress= "1″

Allows or disables the compression of the content cache. The default value is "1", which is: Allow compression.

Eaccelerator.compress_level= "9″

Specifies the compression level of the content cache. The default value is "9", which is the highest level.

Eaccelerator.keys = "Disk_only" eaccelerator.session = "disk_only" eaccelerator.content = "Disk_only"

Set where the content cache is stored, which can be set to:

    • Shm_and_disk in shared cache and hard disk (default value)
    • SHM 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 only stored in shared memory
    • Disk_only is only stored on the hard drive
    • None does not cache data

PHP Extension XCache Installation
XCache module can cache php runtime compile generated opcode can speed up the efficiency of PHP programs, installation XCache and installation Memcache method is similar, are installed in an extended manner, php any extension method is basically the following, So there is no need to specifically find the xxx extension documentation.
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

A message similar to the following is generated

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

All modules will be generated into this directory.
Edit PHP configuration file

# vim/usr/local/php/etc/php.iniextension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xcache.so

Overloaded PHP

# Service PHP-FPM Reload

If it is your apache+php mode, then restart Apache.

# Service httpd Restart

Or

#/usr/local/apache-2.2.27/bin/apachectl Restart

Test results


Articles you may be interested in:

    • Install PHP xcache Extension notes under CentOS 6.3
    • How to install XCache for php5.3 under Ubuntu compilation
    • PHP accelerated eaccelerator Configuration and Usage guide

http://www.bkjia.com/PHPjc/1084565.html www.bkjia.com true http://www.bkjia.com/PHPjc/1084565.html techarticle Configure the Eaccelerator and XCache extensions to accelerate the execution of PHP programs, eaccelerator installation configuration php Acceleration Eaccelerator Introduction Eaccelerator is a free, open source PHP module, it can be ...

  • 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.