Archive for the ‘eAccelerator’ tag
Debian 6(Squeeze)编译搭建shopex或ecshop环境
Debian 6(Squeeze)编译搭建shopex或ecshop环境 Nginx+php5.2.x+Mysql+ZendOptimizer
shopex环境目前只支持php5.2.x,是因为它只支持Zend Optimizer,高版本的Zend Guard是不支持的, 而debian 6 默认安装php是5.3.x,这个版本的php是不支持Zend Optimizer,只支持Zend Guard.所以很矛盾呀,要想使用shopex系统,要么使用debian5 ,但又纠结于想用更高版本的debian6 ,所以我们这里讲述如何在debian6 系统上手动编译安装 支
持shopex环境的搭建。真是没办法,老实说不愿破坏debian自带的软件包管理系统
一、安装nginx
添加nginx源 vi /etc/apt/sources.list
deb http://nginx.org/packages/debian/ squeeze nginx
deb-src http://nginx.org/packages/debian/ squeeze nginx
apt-get update
apt-get install nginx
这样我们就能升级到最新稳定版本的nginx,截至目前是1.0.10
二、安装mysql-server及编译所需库文件
apt-get install mysql-server libmysqlclient15-dev
三、编译安装php5.2.x
准备php编译所需的依赖包
aptitude install libgd2-noxpm-dev libxml2-dev libcurl3-dev libmhash-dev libmcrypt-dev libxslt-dev libpspell-dev libbz2-dev libglobus-openssl-dev
安装编译环境
apt-get install build-essential
下载php3.2.17
wget http://am.php.net/distributions/php-5.2.17.tar.gz
下载php-fpm补丁
wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
gzip -d php-5.2.17-fpm-0.5.14.diff.gz
tar zvxf php-5.2.17.tar.gz
cd php-5.2.17
patch -p1 < ../php-5.2.17-fpm-0.5.14.diff
./configure –prefix=/usr/local/php5 –with-iconv –with-zlib –enable-xml –enable-fastcgi –enable-fpm –with-curl –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-mhash –enable-sockets –with-xmlrpc –enable-zip –with-mysql –with-mysqli –enable-ftp –with-jpeg-dir –with-freetype-dir –with-png-dir –enable-bcmath –enable-calendar –enable-exif –with-openssl –with-bz2
make
make install
cp php.ini-dist /usr/local/php5/lib/php.ini
vi /usr/local/php5/etc/php-fpm.conf
去掉前面的注释
<value name=”user”>nobody</value>
<value name=”group”>nogroup</value>
ln -s /usr/local/php5/sbin/php-fpm /etc/init.d/php-fpm
/etc/init.d/php-fpm start
修改默认主机的配置:
vi /etc/nginx/conf.d/default.conf
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
注意:/usr/share/nginx/html$fastcgi_script_name; 前面的目录是默认主目录的位置,请根据你自己的实际情况修改,默认从nginx.org源安装的nginx最新版本,默认主目录
是/usr/share/nginx/html
/etc/init.d/nginx restart
好了,写个info文件,测试一下nginx+php+mysql是否完美结合了:)
四、安装ZendOptimizer
下载ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz,这是ZendOptimizer的最后一个版本了,也是shopex和ecshop能支持的ZendOptimizer,更高的版本是ZendGuardLoader,
但目前shopex等都不支持呀,非常让人纠结,要不今天我们也不会写这篇文章指导大家搭建合适的环境。
make /usr/local/zend
把解压后的so文件,拷贝到刚才建立的目录
vi /usr/local/php5/lib/php.ini
增加:
zend_extension= /usr/local/zend/ZendOptimizer.so
重启一下 php-fpm 应该马上生效了
自此,shopex或者ecshop的安装环境已经搭建成功。
后续:
五、加入memcache支持
aptitude install memcached
apt-get install m4 autoconf
wget http://pecl.php.net/get/memcache-2.2.6.tgz
tar zvxf memcache-2.2.6.tgz
cd memcache-2.2.6
/usr/local/php5/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
./configure –enable-memcache –with-php-config=/usr/local/php5/bin/php-config –with-zlib-dir
make
make install
Installing shared extensions: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/
修改php.ini
vi /usr/local/php5/lib/php.ini
增加下面4句
extension_dir = “/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/”
extension = memcache.so
memcache.chunk_size = 32768
memcache.hash_strategy = consistent
一般教程都是只加上面2句,建议把下面2句也加上,修改一下默认的一些参数,使memcache的使用性能更加有效率
六、加入eAccelerator支持
wget http://cdnetworks-kr-1.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip
unzip eaccelerator-0.9.6.1.zip
cd eaccelerator-0.9.6.1
/usr/local/php5/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php5/bin/php-config
make
make install
修改php.ini
vi /usr/local/php5/lib/php.ini
extension=”eaccelerator.so”
eaccelerator.shm_size=”32″
eaccelerator.cache_dir=”/var/cache/eaccelerator”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.filter=”"
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”3600″
eaccelerator.shm_prune_period=”3600″
eaccelerator.shm_only=”0″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″
eaccelerator.keys = “disk_only”
eaccelerator.session = “disk_only”
eaccelerator.content = “disk_only”
保存
make /var/cache/eaccelerator
chmod -R 777 /var/cache/eaccelerator
因为之前安装memcache,已经加了extension_dir = “/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/”,所以安装eaccelerator就不加这句了,如果实际操作
中没装memcache,那就需要在php.ini中加入这句,或者直接指定eaccelerator.so的绝对路径
重启一下 php-fpm 应该马上生效了
debian下为PHP安装eAccelerator及配置
1:安装编译环境和php的 dev包
apt-get install build-essential php5-dev bzip2
2:下载并编译eAccelerator
cd /tmp
wget http://cdnetworks-kr-1.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip
unzip eaccelerator-0.9.6.1.zip
cd eaccelerator-0.9.6.1
phpize
./configure
make
make install
安装完毕
3:修改配置文件,有时候可能这个配置文件没有,那就直接创建1个
vi /etc/php5/conf.d/eaccelerator.ini
这里的配置文件路径,可能大家的服务器路径会有所不同,请大家选择自己的php的conf目录
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/var/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"
这里针对小内存vps提几个注意点:
默认配置文件有2个参数要重点注意
eaccelerator.shm_ttl="0"
当共享内存已满时,超过“shm_ttl”秒没有被访问过的脚本将被删除,默认值是“0”秒,表示从来不会删除。
eaccelerator.shm_prune_period="0"
当共享内存已满时,如果有一个新的脚本文件要加入共享内存,但此时共享内存已经用完,这样就会删除在“shm_prune_period”秒之前的未被访问过的脚本缓存,但有个前提就是这个新的脚本文件在“shm_prune_period” 秒之前被执行过。默认值为“0”,意思是不删除任何脚本缓存。
由于vps内存很有限,所以为了最大让缓存利用率提高,大家可以对这2个参数进行调整
eaccelerator.shm_ttl=”3600″
eaccelerator.shm_prune_period=”1800″
以上单位都是秒
4:创建cache目录
mkdir -p /var/cache/eaccelerator
chmod 0777 /var/cache/eaccelerator
ok。重启php-fpm和nginx eAccelerator就生效了
FAQ:
1:如果在编译过程中提示没有phpize这个命令?
解决办法:apti-get install php5-dev
至于eAccelerator的管理,请参考我的另外一篇文章
http://www.5ilinux.com/programming/php/15.html
eAccelerator PHP WEB管理
eAccelerator 对php的加速效果非常不错,默认debian安装eAccelerator没有管理界面,其实还有个Web管理界面
其实管理界面就是一个php文件,我们可以从官方网站下载
http://eaccelerator.net/browser/eaccelerator/trunk/control.php
将其拷贝到web目录
cp control.php /var/www/html(你的web目录)
接着你还需要在修改eAccelerator的配置文件
debian下是:
vi /etc/php5/conf.d/eaccelerator.ini
增加下面一段
eaccelerator.allowed_admin_path=/var/www/html/
重启php-fpm,访问control.php页面,默认账号密码是 admin,eAccelerator
2011年12月3日修正,官方网站那个链接已经失效,不过其实在安装包里已经包含这个文件,解压后寻找control.php这个文件就行