reby 发表于 2013-1-29 23:39:34

WWW服务器php4到php5升级备忘

应开发使用PHP5新特性的需求,考虑到PHP5已经稳定,准定对其进行升级测试,乘机进行几个优化测试。把过程记录如下:

1.PHP5安装
Php5会用到libxml2,所心要先进行安装
# ./configure --prefix=/opt/baobao/install/php/libxml2
# make
# make install

安装php5
# /configure --prefix=/opt/baobao/install/php/ --with-apxs2=/opt/baobao/install/httpd/bin/apxs --with-gd --with-iconv --with-mcrypt=/opt/baobao/install/php/mcrypt --with-zlib --with-libxml-dir=/opt/baobao/install/php/libxml2

2.PHP优化模块eaccelerator安装
# export PHP_PREFIX="/opt/baobao/install/php"
# $PHP_PREFIX/bin/phpize
# ./configure   --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config   --prefix=/opt/baobao/install/php/eaccelerator
# cd /opt/baobao/install/php
# mkdir eaccelerator
# cp lib/php/extensions/no-debug-zts-20060613/eaccelerator.so eaccelerator/

php.ini配置(/opt/baobao/install/php/lib/php.ini)
extension_dir = "/opt/baobao/install/php"
extension="/eaccelerator/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"

3.Apache调整
httpd.conf配置
MaxKeepAliveRequests 60#原来为180

ExpiresDefault "access plus 15 minutes"#原来为5
ExpiresByType text/html "access plus 15 minutes"#原来为10

<IfModule mod_cache.c>
<IfModule mod_mem_cache.c>
    CacheEnable mem /
    MCacheSize 100000
    MCacheMaxObjectCount 10000
    MCacheMinObjectSize 1
    MCacheMaxObjectSize 40960
</IfModule>
CacheDefaultExpire 900
CacheMaxExpire 1800
CacheDisable /angang
</IfModule>


小结:
1.由于内存管理的改变,PHP5内存占用要比PHP4高,在部分内存2G的较差服务器上一度有机器出现load飓高,查看了现为apache进程占用内存高,使用swap所致。后改php.ini的memory_limit = 8M,去掉apache的memory cache得到改善。
2.eaccelerator是PHP的必备好助手,经实测,在高负载机器上load为不使用机器的一半以下。
3.apache的cache在不做代理的机器上意义不是特别大,况且会造成php之类头类型出错。
页: [1]
查看完整版本: WWW服务器php4到php5升级备忘