性能优化(根据需要,自己选择,可不做)
安装eAccelerator
- sudo apt-get install php5-dev
下载 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/
修改php.ini文件,安装为Zend扩展,***放在开头,放到[zend]之前,免的出莫名其妙的问题:
- sudo vi /etc/php5/apache2/php.ini
[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"
创建cache缓存目录
eaccelerator.cache_dir="/var/cache/eaccelerator" 这里定义cache路径
默认值是/tmp/eaccelerator,这非常简单因为任何人都对该目录可写,但是并不明智,因为重启后系统会自动清理该目录。一个更好的地方是/var/cache/eaccelerator。创建该目录并确保它对eAccelerator的使用者可写(通常该用户是你的网络伺服器运行者,可能是www-data)。使用默认值的话这样继续:
- mkdir /tmp/eaccelerator
- chmod 777 /tmp/eaccelerator
改成 /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
复製控制文件control.php到网站根目录
- sudo cp control.php /var/www/htdocs/
修改control.php的$user和$pw,默认是admin和eAccelerator
- sudo vi /var/www/htdocs/control.php
重启apache
- sudo /etc/init.d/apache2 restart
打开 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的安装已经成功。
【编辑推荐】