Ubuntu下Lamp服务器的性能优化

安装Zend Optimizer

要求PHP版本为5.2,不支持Ubuntu10.04的PHP5.3,请参照PHP5.2

下载Zend Optimizer。直接贴下载地址,参考版本号改(这是32位的),不然主页要注册才能下

http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_compsudo mkdir /usr/local/zendsudo cp ZendOptimizer.so /usr/local/zend

编辑php.ini

sudo gedit /etc/php5/apache2/php.ini

开头加入,注意标点符号要英文。

[Zend Optimizer]zend_optimizer.optimization_level=1  zend_extension="/usr/local/zend/ZendOptimizer.so"

重启apache2

sudo /etc/init.d/apache2 restart

还是上面那个phpinfo文件,要能看到如下信息

This program makes use of the Zend Scripting Language Engine:Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

 

 

安裝XCache

sudo apt-get install php5-xcache
root@ubuntu:/home/qii# dpkg -l | grep xcachii  php5-xcache                1.2.2-5                    Fast, stable PHP opcode cacher

xcache配置文件路径是

/etc/php5/conf.d/xcache.ini

编辑php.ini

sudo gedit /etc/php5/apache2/php.ini

把xcache.ini的内容加入到php.ini。重启apache2

sudo /etc/init.d/apache2 restart

检查安装是否成功

root@ubuntu:/home/qii# php -vPHP 5.2.10-2ubuntu6 with Suhosin-Patch 0.9.7 (cli) (built: Oct 23 2009 16:30:10) Copyright (c) 1997-2009 The PHP GroupZend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies with XCache v1.2.2, Copyright (c) 2005-2007, by mOo

 

安装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
phpizesudo ./configure -enable-eaccelerator=sharedsudo make
qii@ubuntu:~/tmp/eaccelerator-0.9.6.1$ sudo make installInstalling 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/eacceleratorsudo chown root:www-data /var/cache/eacceleratorsudo 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.ph

 

posted on 2012-03-30 19:46  zhexiao  阅读(252)  评论(0编辑  收藏  举报

导航