Accelerate PHP with eaccelerator (formerly truck mmcache)

Source: Internet
Author: User
Tags cpanel
What is eaccelerator?
----------------------
Eaccelerator is a free open source PHP accelerator, optimizer, encoder and
Dynamic Content cache for PHP. It increases performance of PHP scripts
Caching them in compiled State, so that the overhead of compiling is almost
Completely eliminated. Also it uses some optimizations to speed up execution
Of PHP scripts. eaccelerator typically reduces server load and increases
Speed of your PHP code by 1-10 times.

Eaccelerator is a fork of turckmmcache

I believe many of my friends know mmcache, but a long time ago, the developer was hired by Zend, so mmcache has never had an official new version... to support the latest php4.3.10 or php5.03, You need to compile the source code by yourself. For common users, it is no different from things... don't be discouraged. We also have eaccelerator!

1. First, we download the compiled module.

Http://www.arnot.info/eaccelerator/

Select to download the eaccelerator corresponding to your system and PHP version

2. rename it as eaccelerator. DLL (WIN version) or eaccelerator. so (for Linux) is then moved to your PHP extention folder, and its path is defined in the PHP. ini

3. Depending on your system, there are generally two installation methods: Zend extension and PHP extension.

If it is the former, add it to your php. ini file.

Zend_extension = "/usr/lib/PhP4/eaccelerator. So" // The Path depends on your system. The file extension is the same, and the DLL is used in win system.
Eaccelerator. shm_size = "16"
Eaccelerator. cache_dir = "/tmp/eaccelerator" // you need to manually create
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 security mode is enabled, it must be used. "zend_extension_ts" I replaces "zend_extension ".

PHP extension installation mode, please add in your php. ini

Extension = "eaccelerator. So" // The Path depends on your system. The file extension is the same. In Windows, the file extension is DLL.
Eaccelerator. shm_size = "16"
Eaccelerator. cache_dir = "/tmp/eaccelerator" // you need to manually create
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"

The eaccelerator can be compatible with Zend, but the above Code is in PHP. INI must be prior to defining Zend-related code, and it is strongly recommended that, unless you must use Zend-related code, it is best not to use Zend and eaccelerator at the same time

After completing the above work, save PHP. ini and restart Apache to see if phpinfo is different? Then, let's see if PHP's execution time is much faster?

The following is a small example of using eaccelerator on the rhle3 + cpanel + Zend accelerator server...

First, I use Windows To Go To The eaccelerator's official website to search for the token next to the token, and then find the token next to eaccelerator-0.9.2a.tar.gz from source forge, then, after obtaining the wget command from the server, I unbind it to/root/eaccelerator /.

Through the following commands, the eaccelerator quickly completed its own security

Export php_prefix = "/usr"

Change the/usr part to your PHP location. You can use locate PHP-config and locate phpize to identify this location. for example, my server gave me the following references:

Root @ Thoth [/] # locate PHP-config
/Home/cpins/installd/buildapache/php-4.3.8/scripts/php-config.in
/Home/cpins/installd/buildapache/php-4.3.8/scripts/PHP-config
/Home/cpapachebuild/buildapache/php-4.3.9/scripts/php-config.in
/Home/cpapachebuild/buildapache/php-4.3.9/scripts/PHP-config
/Home/cpphpbuild/php-4.3.9/scripts/php-config.in
/Home/cpphpbuild/php-4.3.9/scripts/PHP-config
/Usr/bin/PHP-config
/Usr/local/bin/PHP-config
/Usr/local/cpanel/3 rdparty/bin/PHP-config
Root @ Thoth [/] # locate phpize
/Home/cpins/installd/buildapache/php-4.3.8/scripts/phpize. M4
/Home/cpins/installd/buildapache/php-4.3.8/scripts/phpize. In
/Home/cpins/installd/buildapache/php-4.3.8/scripts/phpize
/Home/fanta2/fantastico_files/phpwebsite/lib/pear/build/phpize. M4
/Home/cpapachebuild/buildapache/php-4.3.9/scripts/phpize. M4
/Home/cpapachebuilding/buildapache/php-4.3.9/scripts/phpize. In
/Home/cpapachebuild/buildapache/php-4.3.9/scripts/phpize
/Home/cpphpbuild/php-4.3.9/scripts/phpize. M4
/Home/cpphpbuild/php-4.3.9/scripts/phpize. In
/Home/cpphpbuild/php-4.3.9/scripts/phpize
/Usr/bin/phpize
/Usr/lib/PHP/build/phpize. M4
/Usr/lib/PHP/build/phpize. M4
/Usr/local/bin/phpize
/Usr/local/lib/PHP/build/phpize. M4
/Usr/local/lib/PHP/build/phpize. M4
/Usr/local/cpanel/3 rdparty/bin/phpize
/Usr/local/cpanel/3 rdparty/lib/PHP/build/phpize. M4
/Usr/local/cpanel/3 rdparty/lib/PHP/build/phpize. M4

Because of the above two rows, my php_prefix is/usr.

$ Php_prefix/bin/phpize
./Configure/
-- Enable-eaccelerator = shared/
-- With-PHP-Config = $ php_prefix/bin/PHP-config

Make
Make install

If there is nothing special, the eaccelerator will establish its own security information and then install it.

After completing the compilation, you have to check your phpinfo () to see your configuration file (PHP. INI) path is there. on my server, PHP. INI:/usr/local/Zend/etc/PHP. ini. through the text processing tool (Vi, Picco, etc.), under [Zend,

Reference:
Zend_optimizer.optimization_level = 15
Zend_extension_manager.optimizer =/usr/local/Zend/lib/Optimizer-2.5.7
Zend_extension_manager.optimizer_ts =/usr/local/Zend/lib/Optimizer_TS-2.5.7

Above, add reference:

Zend_extension =/Usr/lib/PHP/extension/ no-debug-non-zts-20020429/eaccelerator. So
Eaccelerator. shm_size =64
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

Please change the above three lines to your server settings. and use chmod 0777 to give your cache_dir information so that eaccelerator can access the cache. after the installation, check if phpinfo has the eaccelerator information from the newly activated Apache through whm, and then check if the PHP Upload time is much faster.

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.