Linux安装PHP7.X
下载PHP安装包并上传到服务器(新建一个文件夹用来存放)
1.安装PHP依赖
yum install gcc libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
2.开始安装PHP
解压安装包
tar -zxf php-7.0.30.tar
进入目录
cd php-7.0.30
复制编译代码
Apache使用非源码编译需要在安装httpd-devel包,否则会缺失aoxs文件夹
./configure \
--prefix=/usr/local/php/php7.0.3 \
--with-apxs2=/usr/local/apache/bin/apxs \
--enable-fpm \
--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
编译并安装:
make && make install
编译完成之后,需要添加PHP命令到环境变量里
vi /etc/profile
在文件末尾加入并保存:
PATH=$PATH:/usr/local/php/php/7.0.30/bin
export PATH
要使改动立即生效执行
source /etc/profile
查看PHP 版本
php -v
[root@iZj6c42f8w148ft2yuv3aeZ apache]# php -v
PHP 7.0.30 (cli) (built: Nov 18 2019 23:54:17) ( ZTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies