您现在的位置是: 首页 >  技术分享 > 

本地环境搭建php7
叶子 2018-05-14 14:12:07

应升级所需,在本地搭建php7环境,简单的安装在这里记录一下。

1、下载php7包
wget -O php7.tar.gz http://cn2.php.net/get/php-7.0.0.30.tar.gz/from/this/mirror
2、下载完成,解压php7安装包
tar -xvf php7.tar.gz
3、安装php的依赖环境,已经安装无需再安装了
yum install 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
4、解压完php7,切换到php7文件夹,执行配置文件
./configure \
--prefix=/opt/php7 \
--with-config-file-path=/opt/php7/lib \
--with-config-file-scan-dir= /opt/php7/lib/php.d \
--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=/opt/php7/php_extend/jpeg\
--with-png-dir=/opt/php7/php_extend/libpng \
--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、编译安装php7,会发现没有php.ini,没有php.ini文件可以去php源码包中拷贝过来一份,直接复制源码包中的php.ini-production
7、如果还有其他php版本存在,需要更改phpfpm的端口号,默认是9000,可以改成9001,或者9002
8、启动php命令
/opt/php7/sbin/php-fpm
9、以上php7安装完毕,接下来安装redis扩展,如下命令
git clone https://github.com/nicolasff/phpredis
git checkout php7
/opt/php7/bin/phpize
./configure --with-php-config=/opt/php7/bin/php-config
make && make install
10、指定php配置文件的路径
/opt/php7/sbin/php-fpm -y /opt/php7/etc/php-fpm.conf -c /opt/php7/lib/php.ini  

yezismile wechat
欢迎关注博主公众号
分享:

Copyright © 2018
www.yezismile.com All rights reserved. 京ICP备15029736号-1