编译安装php7.0.0
参考文档:http://blog.csdn.net/wufei1314a/article/details/52299967
1.下载php7源码包
# cd /root & wget -O php7.tar.gz http://cn2.php.net/get/php-7.0.1.tar.gz/from/this/mirror
2.解压源码包
# 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-devel readline readline-devel libxslt libxslt-devel
安装libmcrypt
wget https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install
4.进入目录
# cd php-7.0.1
5.编译配置,这里如果上一步的某些依赖包没有安装好,就会遇到很多configure error,我们一一解决,安装上相关软件开发包就可以
# ./configure \
--prefix=/usr/local/web/php \
--with-config-file-path=/usr/local/web/php/etc \
--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=/usr/local/libmcrypt \
--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
configure error:
1.configure: error: xml2-config not found. Please check your libxml2 installation.
解决:
1
|
<span style= "color: #ff0000" ># yum install libxml2 libxml2-devel< /span > |
2.configure: error: Cannot find OpenSSL's <evp.h>
解决:
1
|
<span style= "color: #ff0000" ># yum install openssl openssl-devel< /span > |
3.configure: error: Please reinstall the BZip2 distribution
解决:
1
|
<span style= "color: #ff0000" ># yum install bzip2 bzip2 -devel< /span > |
4.configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
解决:
1
|
<span style= "color: #ff0000" ># yum install libcurl libcurl-devel< /span > |
5.If configure fails try --with-webp-dir=<DIR> configure: error: jpeglib.h not found.
解决:
1
|
<span style= "color: #ff0000" ># yum install libjpeg libjpeg-devel< /span > |
6.If configure fails try --with-webp-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.
解决:
1
|
<span style= "color: #ff0000" ># yum install libpng libpng-devel< /span > |
7.If configure fails try --with-webp-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yes
checking for png_write_image in -lpng... yes
If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype-config not found.
解决:
1
|
<span style= "color: #ff0000" ># yum install freetype freetype-devel< /span > |
8.configure: error: Unable to locate gmp.h
解决:
1
|
<span style= "color: #ff0000" ># yum install gmp gmp-devel< /span > |
9.configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决:
# yum install libmcrypt libmcrypt-devel
10.configure: error: Please reinstall readline - I cannot find readline.h
解决:
1
|
<span style= "color: #ff0000" ># yum install readline readline-devel< /span > |
11.configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
解决:
1
|
<span style= "color: #ff0000" ># yum install libxslt libxslt-devel< /span > |
6.编译与安装
# make && make install
这里要make好久,要耐心一下
7.添加 PHP 命令到环境变量
# vim /etc/profile
在末尾加入
PATH=$PATH:/usr/local/web/php/bin
export PATH
要使改动立即生效执行
# source /etc/profile
查看环境变量
# echo $PATH
查看php版本
# php -v
8.配置php-fpm
# cp php.ini-production /etc/php.ini
# cp /usr/local/web/php/etc/php-fpm.conf.default /usr/local/web/php/etc/php-fpm.conf # cp /usr/local/web/php/etc/php-fpm.d/www.conf.default /usr/local/web/php/etc/php-fpm.d/www.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm
PHP-fpm配置参考:http://www.cnblogs.com/yangchunlong/p/8480258.html
9.启动php-fpm
# /etc/init.d/php-fpm start
宝塔界面安装参考:ttps://www.cnblogs.com/paul8339/p/7065799.html
php.ini常用配置项:http://blog.csdn.net/wkupaochuan/article/details/8646738