当前位置: > CentOS > CentOS教程 >

Centos7.2 编译安装PHP7

时间:2018-02-02 13:20来源:linux.it.net.cn 作者:IT

步骤如下:

1、安装依赖

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

 

2、下载PHP源码包

 

wget http://cn2.php.net/distributions/php-7.0.27.tar.gz

 

3、配置参数

 

复制代码
./configure --prefix=/alidata/server/php-7.0.27 \
--with-apxs2=/alidata/server/httpd-2.4.10/bin/apxs \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
复制代码

4、编译

make

注意:我这里报错提示“undefined reference to `libiconv_open'”,make 时增加 ZEND_EXTRA_LIBS=’-liconv’ 参数即可,如下

make ZEND_EXTRA_LIBS='-liconv'

5、安装

 

make install

6、完成安装后需处理

6.1、将 alidata/server/php 软链接设置为 alidata/server/php-7.0.27

cd /alidata/www/server
rm -rf php
ln -s /alidata/server/php-7.0.27 php

6.2、 httpd.conf文件里开启PHP7模块

不开启启动Apache时会报“/etc/rc.d/init.d/httpd: line 79: 29939 Segmentation fault      $HTTPD -k $ARGV”的错误

#LoadModule php5_module        modules/libphp5.so
LoadModule php7_module        modules/libphp7.so

6.4、 重新Apache

systemctl stop httpd
systemctl start httpd


(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容