安装PHP7


#同步时间,因为是在虚拟机上进行的,而虚拟机经常暂停
ntpdate pool.ntp.org

#安装mcrypt
 yum install -y php-mcrypt libmcrypt libmcrypt-devel

#安装bison
wget http://ftp.gnu.org/gnu/bison/bison-2.6.4.tar.gz
tar -xvzf bison-2.6.4.tar.gz 
cd bison-2.6.4
./configure
make && make install

#安装g++
yum whatprovides "*/g++"
yum install gcc-c++-4.4.7-16.el6.x86_64

#安装re2c,这里如果linux上没有安装g++会报错
wget http://sourceforge.net/projects/re2c/files/0.15.3/re2c-0.15.3.tar.gz/download
mv download re2c.tar.gz
tar xf re2c.tar.gz
cd re2c-0.15.3/
./configure --enable-docs
make && make install

#gd库相关依赖,否则会出错
yum -y install libjpeg-devel
ln -s /usr/lib64/libjpeg.so.62 /usr/lib/libjpeg.so

#configure: error: Please reinstall the libcurl distribution
yum -y install curl-devel

#configure: error: png.h not found.
yum install libpng-devel

#configure: error: freetype.h not found.
yum install freetype-devel

#error: mcrypt.h not found. Please reinstall libmcrypt.
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make
make install

#安装php7
wget http://cn2.php.net/get/php-7.0.0.tar.gz/from/this/mirror
mv mirror php7.tar.gz
tar xf php7.tar.gz
mv php7.tar.gz php7
./configure --prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--with-mcrypt=/usr/include \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache
 make && sudo make install

#配置
cp php.ini-production /usr/local/php7/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
chmod +x /etc/init.d/php7-fpm
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf


#查看
/usr/local/php7/bin/php -v
PHP 7.0.0 (cli) (built: Dec  4 2015 18:14:27) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

        【PS】该博客来源与喵了个咪的 PHP7安装笔记,在此基础上添加了踩坑的配置

你可能感兴趣的:(安装PHP7)