在工作中有可能需要多版本的支持,本教程已经安装了lnmp的php5.6版本。再安装php7.1.2
1.安装更新包
yum install epel-release //扩展包更新包
yum update //更新yum源

2.安装mcrypt

yum install -y libmcrypt libmcrypt-devel

3.下载php并安装(下载略)

./configure –prefix=/usr/local/php7 –with-config-file-path=/usr/local/php7/etc –enable-fpm –with-fpm-user=www –with-fpm-group=www –enable-mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-iconv-dir –with-freetype-dir=/usr/local/freetype –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –enable-mbregex –enable-mbstring –enable-intl –enable-pcntl –with-mcrypt –enable-ftp –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –with-gettext –disable-fileinfo –enable-opcache –with-xsl

3.1编译出现错误
/root/php-7.1.2/ext/xmlrpc/libxmlrpc/encodings.c:102: undefined reference to `libiconv_close’
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] 错误 1
解决办法
vi Makefile

找到下面这行:

EXTRA_LIBS = -lcrypt …

在最后添加-liconv
4.配置

cp php.ini-production /usr/local/php7/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
chmod +x /etc/init.d/php7-fpm
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

5.配置opcache
vim /usr/local/php7/etc/php.ini
zend_extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/opcache.so

6.因为之前以及有php5.6已经监听了9000,那么php7就监听9001端口
vi /usr/local/php7/etc/php-fpm.d/php-fpm.conf
listen = 127.0.0.1:9001

7.启动
/etc/init.d/php7-fpm start
8.查看PHP版本
cp /usr/local/php7/bin/php /usr/bin/php7
php7 -v

PHP 7.1.2 (cli) (built: Mar 5 2017 15:43:51) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.2, Copyright (c) 1999-2017, by Zend Technologies

php7install安装说明

Comments are closed.

Post Navigation