1.安装相关依赖所需的文件。
yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel boost boost-doc boost-devel libjpeg libaio libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel epel-release perl-Data-Dumper gcc gcc++ cmake ncurses-devel
2.使用wget
下载php7.1安装包。(在你想安装的位置安装)
wget http://cn2.php.net/distributions/php-7.1.5.tar.gz
3.将文件夹重新命名,不然文件夹看起来太长了 -。-
mv php-7.1.5 php71
4.编译配置(如果出现错误,基本都是第一步的依赖文件没有安装所致)
cd php71
./configure \
--prefix=/wwwdata/software/php7.1 \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache
5.正式安装
make && make install
6.安装完成 successful
Installing shared extensions: /www/software/php71/lib/php/extensions/no-debug-non-zts-20160303/
Installing PHP CLI binary: /www/software/php71/bin/
Installing PHP CLI man page: /www/software/php71/php/man/man1/
Installing phpdbg binary: /www/software/php71/bin/
Installing phpdbg man page: /www/software/php71/php/man/man1/
Installing PHP CGI binary: /www/software/php71/bin/
Installing PHP CGI man page: /www/software/php71/php/man/man1/
Installing build environment: /www/software/php71/lib/php/build/
Installing header files: /www/software/php71/include/php/
Installing helper programs: /www/software/php71/bin/
program: phpize
program: php-config
Installing man pages: /www/software/php71/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /www/software/php71/lib/php/
[PEAR] Archive_Tar - installed: 1.4.2
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.4.2
[PEAR] PEAR - installed: 1.10.4
Wrote PEAR system config file at: /www/software/php71/etc/pear.conf
You may want to add: /www/software/php71/lib/php to your php.ini include_path
/www/software/php71/build/shtool install -c ext/phar/phar.phar /www/software/php71/bin
ln -s -f phar.phar /www/software/php71/bin/phar
Installing PDO headers: /www/software/php71/include/php/ext/pdo/
7.执行下php -v
看看版本
/www/software/php71/bin/php -v
#输出
PHP 7.1.5 (cli) (built: Jul 21 2020 21:31:03) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies