性能优化(根据需要,自己选择,可不做)
安装eAccelerator
sudo apt-get install php5-dev
- 1.
- 2.
下载 eAccelerator
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1
phpize
sudo ./configure -enable-eaccelerator=shared sudo make qii@ubuntu:~/tmp/eaccelerator-0.9.6.1$ sudo make install Installing shared extensions: /usr/lib/php5/20060613+lfs/
- 1.
- 2.
修改php.ini文件,安装为Zend扩展,***放在开头,放到[zend]之前,免的出莫名其妙的问题:
sudo vi /etc/php5/apache2/php.ini
- 1.
- 2.
[eaccelerator]
zend_extension="/usr/lib/php5/20060613+lfs/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"
eaccelerator.allowed_admin_path="/var/www/control.php"
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
创建cache缓存目录
eaccelerator.cache_dir="/var/cache/eaccelerator" 这里定义cache路径
默认值是/tmp/eaccelerator,这非常简单因为任何人都对该目录可写,但是并不明智,因为重启后系统会自动清理该目录。一个更好的地方是/var/cache/eaccelerator。创建该目录并确保它对eAccelerator的使用者可写(通常该用户是你的网络伺服器运行者,可能是www-data)。使用默认值的话这样继续:
mkdir /tmp/eaccelerator
chmod 777 /tmp/eaccelerator
- 1.
- 2.
- 3.
- 4.
改成 /var/cache/eaccelerator的话这样继续,先改php.ini
eaccelerator.cache_dir="/var/cache/eaccelerator"
sudo mkdir /var/cache/eaccelerator
sudo chown root:www-data /var/cache/eaccelerator
sudo chmod u=rwx,g=rwx,o= /var/cache/eaccelerator
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
复製控制文件control.php到网站根目录
sudo cp control.php /var/www/htdocs/
- 1.
- 2.
修改control.php的$user和$pw,默认是admin和eAccelerator
sudo vi /var/www/htdocs/control.php
- 1.
- 2.
重启apache
sudo /etc/init.d/apache2 restart
- 1.
- 2.
打开 http://localhost/control.php

查看之前的info.php页面,有下列字段:
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
上一节:LAMP的安装之XCache优化 到此为止LAMP的安装已经成功。
【编辑推荐】