1、安装php相关依赖包
yum install -y gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel jemalloc jemalloc-devel libpng libpng-devel
2、添加组和用户
添加组
groupadd www
#添加php-fpm用户
useradd -g www www
3、下载二进制包
3.1解压
tar zxvf php-5.6.25.tar.gz
cd php-5.6.25
3.2执行##编译参数
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --disable-fileinfo --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-ftp --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-gd --enable-gd-native-ttf --with-curl --with-zlib --with-xmlrpc --enable-zip --with-bz2 --with-readline --with-freetype-dir --with-png-dir --enable-intl --with-xsl
注:编译时会有报错configure: error: Please reinstall readline - I cannot find readline.h
解决:yum -y install readline-devel
yum -y install libxslt libxslt-devel
再次执行编译
或者报如下错误
解决:
yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker perl-ExtUtils-Embed libicu-devel
再编译
安装
make && make install
4、配置服务
#配置文件
# cp php.ini-development /usr/local/php/etc/php.ini
#php-fpm 服务
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm
# chkconfig --add php-fpm
# chkconfig php-fpm on
# service php-fpm start
vim /usr/local/php/etc/php-fpm.conf
service php-fpm restart
5、添加环境变量(php命令行模式)
# vim /etc/profile
PATH=$PATH:/usr/local/php/bin
export PATH
# source /etc/profile