魏长东

weichangdong

东邪

编译安装php

之前用yum安装了php,但是因为yum的repo源问题,导致php-fpm没有安装成功。然后就试着用编译安装。

yum -y install gcc automake autoconf libtool make
yum -y install gcc gcc-c++ glibc

yum -y install libmcrypt-devel mhash-devel libxslt-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \
krb5 krb5-devel libidn libidn-devel openssl openssl-devel
 
wget http://cn2.php.net/distributions/php-5.4.38.tar.gz
tar zvxf php-5.4.38.tar.gz
cd php-5.4.38
./configure --prefix=/usr/local/php  --enable-fpm --with-mcrypt \
--enable-mbstring --disable-pdo --with-curl --disable-debug  --disable-rpath \
--enable-inline-optimization --with-bz2  --with-zlib --enable-sockets \
--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \
--with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \
--with-gd --with-jpeg-dir
make test
make 
make install

第一次装完,惊奇的发现php居然还是之前的5.16版本,还没有php-fpm。当时我是用了yum erase命令的,吧之前yum install的都erase了,但是这次编译安装完居然这样。

没办法,我又用rpm -e卸载了php,又重新来了一遍。贺!终于ok了!

/usr/local/php/bin/php -v

PHP 5.4.38 (cli) (built: Mar 13 2015 00:20:52) 

/usr/local/php/sbin/php-fpm -v

PHP 5.4.38 (fpm-fcgi) (built: Mar 13 2015 00:21:15)

之前装php-fpm挺顺利的,没遇见啥问题。