Home > Backend Development > PHP Tutorial > Install and configure eaccelerator-0.9.5 to accelerate PHP-5.2.1

Install and configure eaccelerator-0.9.5 to accelerate PHP-5.2.1

angryTom
Release: 2023-04-07 16:04:02
forward
2226 people have browsed it

Operating system: Linux

1. Install eaccelerator-0.9.5 (also supports ZendOptimizer-3.2.2)

1. First install ZendOptimizer -3.2.2

  # wget http://www.vista.ac.cn/linux/down/ZendOptimizer/ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz
  # tar zxvf ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz
  # cd ZendOptimizer-3.2.2-linux-glibc21-i386
  # ./install.sh
Copy after login

In Please specify the location for installing ZendOptimizer: enter the ZendOptimizer installation path after the prompt, for example /data/webserver/zend

In Confirm the location of your php.ini file: prompt and enter the directory where the php.ini file is located, such as /data/webserver/php/etc

. In Specify the full path to the Apache control utility (apachectl): prompt and enter apachectl absolute Path, such as /data/webserver/apache/bin/apachectl

2. Install eaccelerator-0.9.5 acceleration software (recommended learning: PHP video tutorial)

  # wget http://www.vista.ac.cn/linux/down/eaccelerator/eaccelerator-0.9.5.tar.bz2
  # tar jxvf eaccelerator-0.9.5.tar.bz2
  # cd eaccelerator-0.9.5
Copy after login

Specify the path where php is located:

  # export PHP_PREFIX="/data/webserver/php"
  # $PHP_PREFIX/bin/phpize
  # ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
  # make
  # make install
Copy after login

At this time, eaccelerator will be installed in the php directory, and the screen will display the path where eaccelerator.so is located, for example:

Installing shared extensions: /data/webserver/php/lib/php/extensions/no-debug-zts-20060613/

Remember this path.

Eaccelerator can be installed as a PHP extension or as a zend extension. The following installation is a PHP extension.

If the /etc/php.d directory exists, you need to copy eaccelerator.ini to the directory and then modify the default value. If it does not exist, modify php.ini and add the following content before [zend] (note: it must be placed before [zend]):

[eaccelerator]
  extension="/data/webserver/php/lib/php/extensions/no-debug-zts-20060613/eaccelerator.so"
  eaccelerator.shm_size="32"
  eaccelerator.cache_dir="/data/cache/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"
Copy after login

Create a cache directory:

    # mkdir -p /data/cache/eaccelerator
  # chmod 0777 /data/cache/eaccelerator
Copy after login

Restart Apache:

 # service httpd restart
Copy after login

3. Check whether ZendOptimizer and eaccelerator are installed successfully

Create a phpinfo.php file with the following content:

  <?php
      phpinfo();
  ?>
Copy after login

Place the file in Website directory, access it in the browser, if the following content appears, the installation is successful:

  This program makes use of the Zend Scripting Language Engine:
  Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
      with eAccelerator v0.9.5, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
      with Zend Extension Manager v1.0.11, Copyright (c) 2003-2006, by Zend Technologies
      with Zend Optimizer v3.2.2, Copyright (c) 1998-2006, by Zend Technologies
Copy after login

2. Detailed explanation of eaccelerator configuration information (translated according to the official English description)

extension="/data/webserver/php/lib/php/extensions/no-debug-zts-20060613/eaccelerator.so"
Copy after login

Explanation: The path of the PHP extension eaccelerator.so.

--------------------

eaccelerator.shm_size="32"
Copy after login

Explanation: The size of shared memory that can be used by eaccelerator (unit for MB).

Under Linux, the maximum memory usage of a single process is limited by the number (in bytes) set in /proc/sys/kernel/shmmax. For example, the default shmmax value of CentOS 4.4 is 33554432 bytes ( 33554432bytes/1024/1024=32MB).

Temporarily change the value:

# echo 字节数 > /proc/sys/kernel/shmmax
Copy after login

Follow the above method and the value will be automatically restored each time the system is restarted. If you want to make permanent changes, you can modify the /etc/sysctl.conf file and set:

  kernel.shmmax = 字节数
Copy after login

--------------------

  eaccelerator.cache_dir="/data/cache/eaccelerator"
Copy after login

Explanation: For the cache path, you can use the command mkdir -p /data/cache/eaccelerator to create the directory, and then use the command chmod 0777 /data/cache/eaccelerator to set the directory permissions to 0777

-- ------------------

    eaccelerator.enable="1"
Copy after login

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

--------------------

  eaccelerator.optimizer="1"
Copy after login

Explanation: Turn on or off code optimization. Turning on can speed up the execution of the code. speed. "1" means on, "0" means off. The default value is "1".

--------------------

  eaccelerator.check_mtime="1"
Copy after login

Explanation: When this item is turned on, eaccelerator will Check the modification time of the php file to see if it has been modified. This will take a while. If the php file has been modified, eaccelerator will recompile and cache the php file. When this option is turned off, if the PHP file is modified, the eaccelerator cache needs to be manually deleted before the modified PHP file can be displayed. "1" means on, "0" means off. The default value is "1".

--------------------

  eaccelerator.debug="0"
Copy after login

Explanation: Turn on or off debugging logging. When turned on, eaccelerator will log every request for a cache file. Turning this on is only beneficial when debugging whether the eaccelerator has bugs. "1" means on, "0" means off. The default value is "0".

--------------------

  eaccelerator.filter=""
Copy after login

Explanation: Determine which PHP files should be cached. You can specify a range (such as "*.php *.phtml"), so that the specified files will be cached. If the range begins with !, the specified file will not be cached. The default value is "", which means to cache all PHP files.

--------------------

  eaccelerator.shm_max="0"
Copy after login

Explanation: A user can use a function such as eaccelerator_put to share Maximum data loaded in memory. The default value is "0", which means no limit. (Unit is bytes)

--------------------

  eaccelerator.shm_ttl="0"
Copy after login

Explanation: When there is not enough free sharing When memory attempts to buffer a new script, files that have not been accessed for at least shm_ttl seconds ago will be deleted. The default value is "0", which means no attempt will be made to remove any old scripts from shared memory. (Unit is seconds)

--------------------

  eaccelerator.shm_prune_period="0"
Copy after login

解释:当没有足够的空闲共享内存去尝试缓冲一个新脚本时,将删所有旧脚本,前提是这个尝试在超过shm_prune_period秒之前被执行过。默认值为"0",表示不尝试从共享内存中删除任何旧的脚本。(单位为秒)

--------------------

  eaccelerator.shm_only="0"
Copy after login

解释:打开或者关闭在磁盘上缓存编译过的脚本。这个参数对会话数据和内容缓存没有效果。默认值为"0",表示使用磁盘和共享内存来缓存。

--------------------

  eaccelerator.compress="1"
Copy after login

解释:打开或者关闭缓存内容压缩。"1"指打开,"0"指关闭。默认值为"1"。

--------------------

  eaccelerator.compress_level="9"
Copy after login

解释:内存压缩的级别。默认值为"9",表示最大压缩。

  参考资料:

  1、Installing from source (http://www.eaccelerator.net/wiki/InstallFromSource)

  2、eAccelerator settings (http://www.eaccelerator.net/wiki/Settings)

The above is the detailed content of Install and configure eaccelerator-0.9.5 to accelerate PHP-5.2.1. For more information, please follow other related articles on the PHP Chinese website!

source:zyan.cc
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template