PHP Cache Accelerator: Eaccelerator

Source: Internet
Author: User
Tags filter bz2 eval execution install php php file php script zend
Cache

Eaccelerator README for Linux Simplified Chinese Translation

Eaccelerator is a free open-source software that accelerates the PHP program, and its speed effect is never lost to the Zend performance Suite. and support Linux, FreeBSD, Solaris, MacOS X, Windows and other systems.

Today there is nothing to do, the README for Linux files translated for your reference.
The installation part is modified and the installation process is refined.

Where the translation is not exact place also please advise:)

"Translation: Nanu (nanu@discuz.com)"

Eaccelerator for PHP

What is Eaccelerator?

Eaccelerator is an open source and free PHP accelerator, optimizer, encoder, and can also provide PHP
Provides dynamic content caching. It can cache PHP script as compiled state to improve PHP script running performance
, so the traditional precompilation is almost eliminated. Eaccelerator can also optimize PHP scripts to enhance PHP
The execution speed of the script. Eaccelerator can effectively reduce server load and increase PHP program speed by up to 1-10 times.

Turckmmcache is the predecessor of Eaccelerator.
(Http://sourceforge.net/project/turckmm-cache/by Dmitry stogov)

Eaccelerator contains a PHP encoder and loader. You can encode the. php script using the encoder,
This allows you to publish your PHP program in a non source code format. The coded PHP program can run on any installation that has
PHP parsing environment and Eaccelerator site, because the coded PHP program is stored as compiled code, and
The compiled version does not contain the source code for the program, so PHP programs that have been eaccelerator coded cannot be restored
Recovered. Of course, some internal scripts can be used by some different decompile engine tools (such as disassemblers, debuggers, etc.)
For restore recovery, but this is not trivial.

Eaccelerator is compatible with the Zend Optimizer loader. In php.ini, Zend Optimizer must be in
Load after eaccelerator. If your site does not run any PHP scripts encoded via the Zend encoder, then
It is not recommended that you install Zend Optimizer on the server where Eaccelerator is installed.

Eaccelerator cannot run in CGI mode, but it can run in fast-cgi mode similar to LIGHTTPD.

Here are some products that have the same functionality as Eaccelerator:
-Zend Performance Suite (http://www.zend.com)
-Alternative PHP Cache (Http://pecl.php.net/package/APC)


Download

The latest version of Eaccelerator can be downloaded in Sourceforge:
http://sourceforge.net/projects/eaccelerator/
The CVS development version Snapshot (snapshots) can be downloaded at the following address:
Http://snapshots,eaccelerator.net


The desired environment

Apache version 1.3 or higher
mod_php version 4.1 or higher
Autoconf
Automake
Libtool
M4


Compatibility

After user's use and report, Eaccelerator can run in PHP4 and PHP5. PHP5.1 is not yet complete.
Support. Eaccelerator can work with Apache 1.3/2.0, lighttpd, and IIS on Linux, FreeBSD, MacOS X, Solaris, and
Run on Windows.


Quick Install

You can get more information about the installation at the Eaccelerator site.
http://eaccelerator.sourceforge.net/

Note (1): For installation information on the Microsoft Windows platform, please read Readme.win32 file.

Step 1. Compiling eaccelerator

Cd/usr/local/src

wget HTTP://INTERNAP.DL.SOURCEFORGE.N ... rator-0.9.4.tar.bz2

Tar xjvf eaccelerator-0.9.4.tar.bz2

CD eaccelerator-0.9.4.tar.bz2

Export php_prefix= "/usr/local/php"

$PHP _prefix/bin/phpize

./configure \
--enable-eaccelerator=shared \
--with-php-config= $PHP _prefix/bin/php-config

Make

You must specify the location of the actual PHP installation directory in the Export command. The directory location may be "/usr" "/usr/local", or
Other locations.

Step 2. Install Eaccelerator

Make install

Step 3. Configure Eaccelerator

Eaccelerator can be installed as Zend extensions or PHP extensions.

For Eaccelerator 0.9.1 and above, if the/ETC/PHP.D directory exists on your system, you will need to Eaccelerator.ini
File to the directory, and modify the default settings and values as needed.

If the/ETC/PHP.D directory does not exist in the system, edit the php.ini file (usually located in/etc/php.ini).

Install as Zend extension:

zend_extension= "/usr/lib/php4/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"

If you compile and install PHP with thread safe, you must use "Zend_extension_ts" instead of "zend_extension".

Install as PHP extension:

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"

Step 4. Create cache Directory

Mkdir/tmp/eaccelerator
CHOMD 0777/tmp/eaccelerator


Configuration options

Eaccelerator.shm_size
Specifies the amount of shared memory that Eaccelerator can use in megabytes (MB).
"0" represents the operating system default. The default value is "0".

Eaccelerator.cache_dir
Directory for user disk caching. Eaccelerator Stores precompiled code, session data, content, and so on in this directory.
The same data can also be stored in shared memory (for faster access speed). The default value is "/tmp/eaccelerator".

Eaccelerator.enable
Turn eaccelerator on or off. "1" is turned on, "0" is closed. The default value is "1".

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

Eaccelerator.debug
Turn debug logging on or off. "1" is turned on, "0" is closed. The default value is "0".

Eaccelerator.check_mtime
Turn on or off the PHP file change check. "1" is turned on, "0" is closed. If you want to recompile PHP after you modify it
The program needs to be set to "1". The default value is "1".

Eaccelerator.filter
Determine which PHP files must be cached. You can specify the cached and not cached file types (such as "*.php *.phtml", and so on)
If the arguments begin with "!", the files that match the parameters are ignored. The default value is "", that is, all PHP files
will be cached.

Eaccelerator.shm_max
Prevents large files from being stored in shared memory when the Eaccelerator_put () function is used. This parameter specifies the allowed
Maximum storage value, in bytes (10240, 10K, 1M). "0" is not limited. The default value is "0".

Eaccelerator.shm_ttl
When Eaccelerator fails to get the shared memory size of the new script, it will remove all in the shared memory from the
The last "Shm_ttl" second script cache that cannot be accessed. The default value is "0", that is: Do not remove from the shared spring
Any cached files.

Eaccelerator.shm_prune_period
When Eaccelerator fails to get the shared memory size of the new script, he will attempt to remove it from shared memory earlier than
Cache script for "shm_prune_period" seconds. The default value is "0", that is: Do not remove from the shared spring
Any cached files.

Eaccelerator.shm_only
Allows or disables caching of compiled scripts on disk. This option is not valid for session data and content caching. Default
The value is "0", that is, caching using disk and shared memory.

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

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

Eaccelerator.name_sapce
A prefix string for all keys (keys). If the prefix string is set, the. htaccess or master configuration is allowed.
The file runs two identical key names on the same host.

Eaccelerator.keys
Eaccelerator.sessions
Eaccelerator.content
Determine which keys (keys), session data, and content will be cached. The available parameter values are:
"Shm_and_disk"-caching data both in shared memory and on disk (default value);
"SHM"-if shared memory runs out or the data capacity is greater than "Eaccelerator.shm_max"
Caching data in shared memory or disk;
"Shm_only"-caching data only in shared memory;
"Disk_only"-caching data only on disk;
' None '-disables caching of data.


Eaccelerator Application Interface (API)

Eaccelerator_put ($key, $value, $ttl =0)
Stores the $value in shared memory and stores $tll seconds.

Eaccelerator_get ($key)
Returns the cached value stored by the Eaccelerator_put () function from shared memory if it does not exist or is already
Expires, NULL is returned.

EACCELERATOR_RM ($key)
Deletes the $key from shared memory.

EACCELERATOR_GC ()
Delete all expired keys (keys)

Eaccelerator_lock ($lock)
Creates a lock with the specified name. The lock can be lifted through the Eaccelerator_unlock () function, in the request
It is also unlocked automatically at the end. For example:
<?php
Eaccelerator_lock ("Count");
Eaccelerator_put ("Count", Eaccelerator_get ("Count") +1);
?>

Eaccelerator_unlock ($lock)
Unlocks the specified name (lock).

Eaccelerator_set_session_handlers ()
Installs the eaccelerator session handle.
After you have 4.2.0 from PHP, you can set the "Session.save_handler=eaacelerator" in php.ini
Install the eaccelerator handle.

Eaccelerator_cache_output ($key, $eval _code, $ttl =0)
$eval _code output is cached in shared memory, $ttl seconds are cached.
You can call the MMCACH_RM () function to delete output from the same $key. For example:
<?php eaccelerator_cache_output (' Test ', ' echo Time '); Phpinfo ();?>

Eaccelerator_cache_result ($key, $eval _code, $ttl =0)
Cache $eval _code results in shared memory, $ttl seconds cached.
You can call the MMCACH_RM () function to delete the results of the same $key. For example:
<?php eaccelerator_cache_output (' Test ', ' time () '). Hello ";",?>

Eaccelerator_cache_page ($key, $ttl =0)
The entire page is cached and $ttl seconds are cached. For example:
<?php
Eaccelerator_cache_page ($_server[' php_self '). " Get= '. Serialize ($_get), 30);
echo Time ();
Phpinfo ();
?>

Eaccelerator_rm_page ($key)
Deletes the same $key page created by the Eaccelerator_cache_page () function from the cache.

Eaccelerator_encode ($filename)
Returns the compiled encoding of the $filename file.

Eaccelerator_load ($code)
Loads the script encoded by the Eaccelerator_encode () function.


WEB interface

WEB-Interface based management can be done through eaccelerator.php. Of course, you need to store the file on your WEB site
Table of Contents. For security reasons, it is recommended that you have security control over this file to ensure that only local IP can read the file.

Starting with version 2.3.18, the Admin interface can be password protected. Run eaccelerator_password.php from the terminal command line and
Follow these steps to generate a password:

$ php-q eaccelerator_password.php
Change the eaccelerator WEB admin interface password. (eaccelerator.php)

Enter Admin Name:admin
New Admin Password:eaccelerator
Retype new admin Password:eaccelerator

Add the following in php.ini and restart the WEB service:
Eaccelerator.admin.name= "Admin"
Eaccelerator.admin.password= "$1$0scd9gkb$noemfernmvq576helelrg0"

Eaccelerator Administrator username and password if eaccelerator.php is stored in a HTTPD password-protected directory
Must be consistent.


Contact Us

You can contact us to report BUGS, questions or patches. Send an email to Bart vanbrabant
<zoeloelip at users.sourceforge.net>




Related Article

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.