PHP7.1
安装包目录:
# pwd
/root/soft
下载:
# wget http://cn2.php.net/distributions/php-7.1.11.tar.gz
解压并安装:
# tar -zxvf php-7.1.11.tar.gz
# yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
# cd php-7.1.11
# ./configure --prefix=/usr/local/php-7.1.11 --exec-prefix=/usr/local/php-7.1.11 --bindir=/usr/local/php-7.1.11/bin --sbindir=/usr/local/php-7.1.11/sbin --includedir=/usr/local/php-7.1.11/include --libdir=/usr/local/php-7.1.11/lib/php --mandir=/usr/local/php-7.1.11/php/man --with-config-file-path=/usr/local/php-7.1.11/etc --with-mcrypt=/usr/include --with-mhash --with-openssl --with-mysqli --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --without-gdbm --disable-fileinfo --enable-intl
# make && make install
复制配置:
# cp php.ini-development /usr/local/php-7.1.11/etc/php.ini
查看版本:
# /usr/local/php-7.1.11/bin/php -v
PHP 7.1.11 (cli) (built: Nov 6 2017 15:11:13) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
查看扩展:
# /usr/local/php-7.1.11/bin/php -m
...
备注:
nginx解析php问题,这里不在累赘.
可能出现的错误:
Error:
configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
Resolution:
CentOS / RedHat: yum install libicu-devel
Ubuntu/Debian: sudo apt-get install libicu-dev
PHP5.6
下载
wget http://cn2.php.net/get/php-5.6.32.tar.gz/from/this/mirror
安装
groupadd www
useradd -g www www
tar xzvf mirror
./configure \
--prefix=/usr/local/php-5.6.32 \
--with-config-file-path=/usr/local/php-5.6.32/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 \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip
配置
直接把源码底下的php.ini-*
复制到PHP的etc目录即可. 需要哪个就把哪个重命名为php.ini
拓展
1 如果同一个扩展(swoole什么的)在不同的php版本中安装,最好编译之前清理一下编译缓存:
make clean
make clean all
2 配置文件选择的时候,根据场景选择,不要再线上环境出现开发时候的配置项,避免安全风险产生.
3 就这样吧,想起来有啥要补充,在继续添加