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

復(fù)制配置:

# 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

查看擴(kuò)展:

# /usr/local/php-7.1.11/bin/php -m
...

備注:

nginx解析php問題,這里不在累贅.


可能出現(xiàn)的錯誤:

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-*復(fù)制到PHP的etc目錄即可. 需要哪個就把哪個重命名為php.ini

拓展

1 如果同一個擴(kuò)展(swoole什么的)在不同的php版本中安裝,最好編譯之前清理一下編譯緩存:

make clean
make clean all

2 配置文件選擇的時候,根據(jù)場景選擇,不要再線上環(huán)境出現(xiàn)開發(fā)時候的配置項,避免安全風(fēng)險產(chǎn)生.

3 就這樣吧,想起來有啥要補充,在繼續(xù)添加

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容