今天下载了php5.3.5,立刻在Freebsd7.4下安装测试一番,安装过程如下:

fastcgi方式

先安装需要的支持

tar zxvf zlib-1.2.5.tar.gz
cd zlib-1.2.5
./configure --prefix=/usr
make
make install

tar zxvf libpng-1.5.1.tar.gz
cd libpng-1.5.1

./configure --disable-shared --prefix=/usr
make
make install

pkg_add ca_root_nss-3.12.6.tbz
pkg_add curl-7.21.3.tbz
pkg_add freetds-0.64_6,1.tbz
pkg_add freetype-1.3.1_4.tbz
pkg_add jpeg-8_3.tbz
pkg_add libmcrypt-2.5.8.tbz
pkg_add libxml2-2.7.8_1.tbz
pkg_add mcrypt-2.6.8_1.tbz
pkg_add mhash-0.9.9.9_1.tbz
pkg_add mysql-client-5.1.55.tbz
pkg_add openssl-1.0.0_5.tbz
pkg_add perl-5.10.1_3.tbz
pkg_add png-1.4.5.tbz
pkg_add gd-2.0.35_7,1.tbz

解压进入目录

tar zxvf php-5.3.5.tar.gz
cd php-5.3.5

编译选项,大家根据需要自己选择,详细请查看 ./configure --help
因为php5.3无需再安装fpm补丁,直接使用fpm选项即可

./configure
--prefix=/myserver/soft/php
--with-config-file-path=/myserver/soft/php/etc
--with-bz2=/usr
--with-mhash=/usr
--with-mcrypt=/usr
--with-curl=/usr
--with-libxml-dir=/usr
--with-iconv-dir=/usr
--with-freetype-dir=/usr
--with-jpeg-dir=/usr
--with-png-dir=/usr
--with-zlib-dir=/usr
--with-mysql=/usr
--with-mssql
--with-gd
--with-openssl
--with-curlwrappers
--with-mysqli
--enable-safe-mode
--enable-bcmath
--enable-shmop
--enable-sysvsem
--enable-inline-optimization
--enable-mbregex
--enable-mbstring
--enable-zip
--enable-ftp
--enable-sockets
--enable-calendar
--enable-gd-native-ttf
--enable-xml
--enable-fpm
--enable-sysvmsg
--enable-soap
--disable-debug
--disable-rpath

编译安装

make
make install
cp php.ini-development /myserver/soft/php/etc/php.ini 生成的文件名和之前的版本以前略有不同

安装memcache

pkg_add autoconf-2.68.tbz

tar zxvf memcache-3.0.5.tgz
cd memcache-3.0.5/
/myserver/soft/php/bin/phpize
./configure --with-php-config=/myserver/soft/php/bin/php-config
make
make install
cd ../

安装ea

tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/myserver/soft/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/myserver/soft/php/bin/php-config
make
make install
cd ../

设置扩展查找目录以及配置

ee /myserver/soft/php/etc/php.ini
查找extension_dir
extension_dir = "/myserver/soft/php/lib/php/extensions/no-debug-non-zts-20090626/"
extension = "memcache.so"

[eaccelerator]
zend_extension="/myserver/soft/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/myserver/soft/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"


mkdir /myserver/soft/eaccelerator_cache 建立缓存目录

复制fpm配置文件

cp /myserver/soft/php/etc/php-fpm.conf.default /myserver/soft/php/etc/php-fpm.conf

更改运行用户和用户组

user www
group www

至此,顺利安装完毕,用/myserver/soft/php/sbin/php-fpm启动进程。