EAccelerator (PHP code accelerator)

Source: Internet
Author: User
EAccelerator configuration (PHP code accelerator) eAccelerator is a free and open source php accelerator that optimizes and dynamically caches content, improves the cache performance of php scripts and enables PHP scripts to be compiled, the server overhead is almost completely eliminated. It also optimizes scripts to accelerate eAccelerator configuration (PHP code accelerator)


EAccelerator is a free and open source php accelerator. It optimizes and dynamically caches content, improves the cache performance of php scripts, and completely eliminates the server overhead when PHP scripts are compiled. It also optimizes scripts to accelerate execution efficiency. Improve the code execution efficiency of your PHP program by 1-10 times;

?

First, you must install PHP and then compile and install eaccelerator. the procedure is as follows.
Our official version from below is eaccelerator-0.9.5.2.tar.bz2
Compile and install;
# Tar xvf eaccelerator-0.9.5.2.tar.bz2
# Cd eaccelerator-0.9.5.2
# Export PHP_PREFIX = "/usr"
# $ PHP_PREFIX/bin/phpize
#./Configure \ -- enable-eaccelerator = shared \ -- with-php-config = $ PHP_PREFIX/bin/php-config
# Make
# Make install
Note: Use export to set the installation path variable of php. My PHP is installed in the/usr directory, and the system uses redhat. For other systems, the default installation method is similar. for different systems, specify the default one;
After installation, eaccelerator. the so module is located in the/usr/lib/php/extensions directory. if your system is different from me, where should you install it yourself; # echo "/usr/lib/php/extensions">/etc/ld. so. conf
# Ldconfig note: Update the dynamic link library address;
Modify the configuration file;
First, modify php. ini and restart Apache;
In the php. ini file, add;
Zend_extension = "/usr/lib/php/extensions/eaccelerator. so" note: the specific position of the module;
Eaccelerator. shm_size = "16" note: Shared memory size;
Eaccelerator. cache_dir = "/home/eaccelerator" note: cache directory;
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" note: the specific position of the module must be correct, which is subject to your system; the shared memory size can be adjusted by yourself, and 16 MB is still available, depending on the server, you can call it yourself.
You can specify the cache directory by yourself. here we specify the eaccelerator directory on the/home directory. if not, create one by yourself. The permission is 0777;
The above configuration is to compile the eaccelerator as the Zend extension module. If your PHP is compiled in installation mode, change zend_extension to zend_extension_ts.
If you use eaccelerator as an extension of PHP, use the following configuration;
Extension = "eaccelerator. so"
Eaccelerator. shm_size = "16"
Eaccelerator. cache_dir = "/home/eaccelerator"
Eaccelerator. enable = "1"
Eaccelerator. optimizer = "1"
Eaccelerator. check_mtime = "1"
Check whether it is effective. in the/home/eaccelerator Directory, when the Apache server is started, you can click a few pages. if the directory contains a file. It takes effect. If there are no files, you have to find the reason ...... Are these two configuration files useful. You need to modify it as needed.
# Mkdir/home/eaccelerator
# Chmod 777/home/eaccelerator note: create a cache directory pool with a permission of 777

?

?


Eaccelerator. shm_size = "32"

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. 16, 32, and 64,128 are acceptable.

Eaccelerator. cache_dir = "/home/php/tmp"

This directory is used for disk cache. here, eAccelerator stores pre-compiled code, process data, content, and user-defined content. the same data can also be stored in the shared memory (this can increase the access speed ). the default value is "/tmp/eaccelerator ".

Eaccelerator. enable = "1"

Enable or disable eAccelerator. "1" is enabled, and "0" is disabled. The default value is "1 ".

Eaccelerator. optimizer = "1"

Enable or disable the internal Optimizer to speed up code execution. "1" is enabled, and "0" is disabled. The default value is "1 ".

Eaccelerator. check_mtime = "1"

Open or close the PHP file modification check. "1" indicates opening, "0" indicates closing. if you re-compile the PHP file after modification, you should set it to "1 ". the default value is "1 ".

Eaccelerator. debug = "0"

Enable or disable debugging logging. "1" is enabled, and "0" is disabled. The default value is "0 ". Logs will be written to the cache hit records.

Eaccelerator. filter = ""

Determine which PHP files must be cached. You can specify cache and non-cache file types (such as "*. php *. phtml)

If the parameter is set "! ", Files matching these parameters are ignored. The default value is "", that is, all PHP files will be cached.

Eaccelerator. shm_max = "0"

When the "eaccelerator_put ()" function is used, it is prohibited to store excessive files in the shared memory. This parameter specifies the maximum value that can be stored, in bytes (10240, 10 K, 1 M ). "0" is unlimited. The default value is "0 ".

Eaccelerator. shm_ttl = "0"

When the eAccelerator fails to obtain the shared memory size of the new script, it will delete all script caches that have not been accessed in the last "shm_ttl" seconds from the shared memory. The default value is "0". that is, no cached files are deleted from the shared files in the spring.

Eaccelerator. shm_prune_period = "0"

When the eAccelerator fails to get the shared memory size of the new script, it will try to delete the cache script earlier than "shm_prune_period" from the shared memory. The default value is "0". that is, no cached files are deleted from the shared files in the spring.

Eaccelerator. shm_only = "0"

Allow or disable caching compiled scripts on disks. This option is invalid for session data and content caching. The default value is "0", that is, the disk and shared memory are used for cache.

Eaccelerator. compress = "1"

Allows or disables content caching. The default value is "1", that is, compression is allowed.

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 the location where the content cache is stored. you can set it:

Shm_and_disk in shared cache and hard disk (default)

Shm has shared memory by default. if the shared memory is full or the size exceeds the value of "eaccelerator. shm_max", it is saved to the hard disk.

Shm_only is stored only in the shared memory.

Disk_only is stored on the hard disk

None

Eaccelerator. allowed_admin_path = "/var/www/html/web/eaccelerator"

This is the control panel address.

The installation package contains control. php. you can copy it to any directory on the website and use it to view and manage it. this must be specified. Otherwise, an error occurs when you view the cached content.

Finally, let's take a look at my eAccelerator settings.

; Eaccelerator

[Eaccelerator]

Zend_extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator. so"

Eaccelerator. shm_size = "128"

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 = "3600"

Eaccelerator. shm_prune_period = "3600"

Eaccelerator. shm_only = "0"

Eaccelerator. compress = "1"

Eaccelerator. compress_level = "9"

Eaccelerator. keys = "disk_only"

Eaccelerator. sessions = "disk_only"

Eaccelerator. content = "disk_only"

Eaccelerator. allowed_admin_path = "/var/www/html/web/eaccelerator"

In addition, let's talk about installing eAccelerator.

# Wget http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2

# Tar-jxvf eaccelerator-0.9.6.tar.bz2

# Cd eaccelerator-0.9.6

#/Usr/local/php/bin/phpize

#./Configure -- enable-eaccelerator = shared -- with-php-config =/usr/local/php/bin/php-config

# Make & make install


-------------------------------------
One of the solutions to access problems after open_basedir is set

Warning: Unknown: open_basedir restriction in effect. File () is not within the allowed path (s): (.:/tmp/) in Unknown on line 0

Fatal error: Can't load/XX/index. php, open_basedir restriction. in Unknown on line 0

There have been many such problems, and I feel like I have no way to start. I always think it is related to the system and php. today I have appeared again. it is not surprising to think about it. I will re-compile php later, php extensions are not compiled, but no error occurred when setting open_basedir ^ ?? ,?? From this information, I think some of them can be used. I installed all the extensions required by my solution. When I restarted apache, I found this error. the extensions set in ini are closed one by one and start troubleshooting. after the eaccelerator is commented out, there is no error after apache is restarted. if the problem is located, the eaccelerator is located and checked by google, we found that the version 0.9.6 of the eaccelerator has changed somewhat from the previous one. we have restricted open_basedir. in this case, we need to remove the restriction.

Do not install the eaccelerator 0.9.6 after downloading it. unpackage the eaccelerator and find the eaccelerator. c File. open row 1,156th, as shown in the following figure:
If (PG (open_basedir) & php_check_open_basedir (realname TSRMLS_CC )){
Modify:
If (PG (open_basedir) & php_check_open_basedir (file_handle-> filename TSRMLS_CC )){

After the modification, it will be OK after compilation.

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.