Posted by zuzhihui in vps技术 on 2009/09/07 with No Comments
php-fpm和spawn-fcgi一样,是一个php的fastcgi进程管理器。spawn-fcgi是个独立的程序,而php-fpm是和php集成在一起的。一般的Linux都不带php-fpm,本文介绍在ubuntu 9.04 VPS下怎样编译php-fpm。
首先查看ubuntu的apt软件库的配置,确保/etc/apt/sources.list这个文件里面至少有:
deb http://archive.ubuntu.com/ubuntu jaunty main universe multiverse
deb http://security.ubuntu.com/ubuntu jaunty-security main universe multiverse
然后同步一下:
apt-get update
安装编译工具:
apt-get install build-essential vim
安装编译所需要的库:
apt-get install libxml2-dev libmcrypt-dev libssl-dev libldap2-dev libmhash-dev libmysqlclient-dev libcurl4-openssl-dev libpng-dev libjpeg-dev
libfreetype6-dev libsasl2-dev
下载php 5.2.10和相应的php-fpm补丁,然后开始编译:
tar zxf php-5.2.10.tar.gz
cd php-5.2.10
cat ../php-5.2.10-fpm-0.5.13.diff | patch -p1
./configure --prefix=/opt/php --with-iconv --with-zlib --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --with-mysql --with-mysqli --enable-sqlite-utf8 --with-pdo-mysql --enable-ftp
--with-jpeg-dir
--with-freetype-dir
--with-png-dir
make
make install
cp php.ini-dist /opt/php/lib/php.ini
ln -s /opt/php/sbin/php-fpm /etc/init.d/php-fpm
update-rc.d -f php-fpm defaults
/etc/init.d/php-fpm start
编译后的php安装在/opt/php下面,php的配置文件是/opt/php/lib/php.ini
然后运行 /etc/init.d/php-fpm
start 就可以启动php的fastcgi进程了,这些php fastcgi进程应该可以正常工作了。
编辑php-fpm的配置文件/opt/php/etc/php-fpm.conf,
tar jxf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3
apt-get install -y autoconf
/opt/php/bin/phpize
./configure --enable-eaccelerator --with-php-config=/opt/php/bin/php-config
make
make install
mkdir /opt/php/eaccelerator_cache
然后vim /opt/php/lib/php.ini,在文件末尾加入:
[eaccelerator]
zend_extension="/opt/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/opt/php/eaccelerator_cache"
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"
然后重启php-fpm,在phpinfo()页面中应该能看到eaccelerator的信息了。
我们把/opt/php目录打包为php-fpm-5.2.10-amd64.tar.gz,放到 http://dl.rashost.com 下面,供客户下载使用。
要发表评论,您必须先登录。
近期评论