Install Zend Optimizer and eAccelerator in CentOS

Source: Internet
Author: User
Tags download zend

Zend optimizer is used to optimize php code. During php Execution, after the php file is read from the disk to the memory, the code in the php file should be compiled to generate OPCODE, then Zend engine runs the Opcode. Zend Optimizer is used to optimize the compiled OPcode. Originally, I wanted to install it on Ubuntu. Unfortunately, ZO does not support 5.3 for the time being, so I had to install it on CentOS. The default php5.1.6 version is installed in CendOS.

Previously, this item was installed on the company's computer. Now I have to tidy up my computer. To test the effect, I first ran a ghost PHP file. The running result is as follows:

Easy 0.463
Simplecall 0.357
Simplecuall 0.581
Simpleudcall 0.633
Mandel 0.936
Mantel2 1.238
Ackermann (7) 0.665
Ary (1, 50000) 0.089
Army2 (50000) 0.048
Ary3 (2000) 0.430
Fiber (30) 1.617
Hash1 (50000) 0.068
Hash2 (500) 0.077
Heapsort (20000) 0.255
Matrix (20) 0.252
Nestedloop (12) 0.508
Sieve (30) 0.239
Strcat (200000) 0.047
Total 8.503

The Unit is in seconds. After Zend Optimizer is installed, run it again to check whether the running time has been improved.
Download Zend Optimizer first
Http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
I downloaded the i386 version. If you need to download the 64-bit version, you can download the corresponding version.
# Tar-xzvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
# Cd ZendOptimizer-3.3.9-linux-glibc23-i386
# Cd data
# Cd 5_rjx_comp
# Cp ZendOptimizer. so/usr/lib/php/modules/
Then modify the/etc/php. ini configuration file.

Add the following two lines
Zend_optimizer.optimization_level = 15 # How many optimization processes are started
Zend_extension =/usr/lib/php/modules/ZendOptimizer. so

Restart the httpd service and use phpinfo () to view the result.
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
With Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
Indicates that Zend Optimizer has been successfully installed. Now that the installation is complete, run the ghost file again to see how it works:

Easy 0.252
Simplecall 0.401
Simplecuall 0.665
Simpleudcall 0.561
Mandel 0.831
Mantel2 1.089
Ackermann (7) 0.689
Ary (1, 50000) 0.065
Army2 (50000) 0.047
Ary3 (2000) 0.420
Fiber (30) 1.566
Hash1 (50000) 0.078
Hash2 (500) 0.084
Heapsort (20000) 0.279
Matrix (20) 0.236
Nestedloop (12) 0.427
Sieve (30) 0.223
Strcat (200000) 0.044
Total 7.956

Running several times, basically stable at around 8 s, about 0.5 s faster than before the installation, there is a gap than imagined, it seems that the optimization effect is limited, however, this is also related to my test data. The test is not comprehensive. This is the first step here. Next, install the eAccelerator to see the effect of the combination of the two.
He.
Or download the eAccelerator first. For more information about this accelerator, see: http://baike.baidu.com/view/1376127.htm? Fr = ala0_1_1
Http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2 for eAccelerator

# Bzip2-d eaccelerator-0.9.6.tar.bz2
# Tar-xvf eaccelerator-0.9.6.tar
# Cd eaccelerator-0.9.6
#/Usr/bin/phpize
#./Configure -- enable-eaccelerator = shared -- with-php-config =/usr/bin/php-config
# Make
# Cp modules/eaccelerator. so/usr/lib/php/modules/
Pay attention to the corresponding path of your machine, and then configure the php. ini file.
# Vim/etc/php. ini
Add the following information:
[Eaccelerator]
Extension = eaccelerator. so
Eaccelerator. shm_size = 64; here is the size of the shared memory used by the accelerator
Eaccelerator. cache_dir =/tmp/eaccelerator
Eaccelerator. enable = 1
Eaccelerator. optimizer = 1
Eaccelerator. check_mtime = 1
Eaccelerator. debug = 0
Eaccelerator. log_file =/var/log/httpd/eaccelerator. log
Eaccelerator. filter =
Eaccelerator. shm_max = 0
Eaccelerator. shm_ttl = 0
Eaccelerator. shm_prune_period = 0
Eaccelerator. shm_only = 0

The specific meaning of options here are explained in detail: html/open-php/qitakaiyuan/2010/0511/4487.html "> http://www.php100.com/html/open-php/qitakaiyuan/2010/0511/4487.html

After modifying the php. ini file, set the permission of the cache folder.
# Mkdir/tmp/eaccelerator
# Chmod 777/tmp/eaccelerator
Restart the httpd server and view phpinfo (). The following records are available:
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
With eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
With Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
It indicates that the eAccelerator is successfully installed. Now let's take a look at the optimization effects of the two.

Easy 0.243
Simplecall 0.381
Simplecuall 0.525
Simpleudcall 0.612
Mandel 0.856
Mantel2 1.054
Ackermann (7) 0.669
Ary (1, 50000) 0.049
Army2 (50000) 0.043
Ary3 (2000) 0.395
Fiber (30) 1.601
Hash1 (50000) 0.082
Hash2 (500) 0.076
Heapsort (20000) 0.237
Matrix (20) 0.223
Nestedloop (12) 0.393
Sieve (30) 0.218
Strcat (200000) 0.041
Total 7.698

It is almost as fast as s, so the combination of the two has indeed played a role in accelerating the execution speed. Although there is not much time to reduce, it may be related to the problems in my test file, because it is mainly for computing and has high cpu requirements, it is good to reduce the execution time of nearly one second. This is now written here, the specific internal mechanism will be further studied.
 

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.