天天看點

php5.6下載下傳跟7.1,PHP 安裝(7.1/5.6)

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 就這樣吧,想起來有啥要補充,在繼續添加