教你编译PHP7 (nginx+mysql+php7)

# 安装编译工具:
yum install gcc automake autoconf libtool gcc-c++

# 安装基础库
yum install gd zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel

 

# 安装mysql
yum install mysql mysql-server

 

# 下载pcre 正则库
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.bz2
tar jxf pcre-8.37.tar.bz2

 

#编译nginx
cd /usr/local/src

wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar zxf nginx-1.8.0.tar.gz

cd nginx-1.8.0
./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/src/pcre-8.37
make && make install

 

# 编译PHP
cd /usr/local/src
wget http://cn2.php.net/get/php-7.0.0.tar.bz2/from/this/mirror
mv mirror php-7.0.0.tar.bz2
tar jxf php-7.0.0.tar.bz2

cd php-7.0.0

./configure --prefix=/usr/local/php \
--with-gd \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-mcrypt \
--enable-mbstring \
--enable-zip \
--enable-fpm

make && make install

# 复制配置文件
cp /usr/local/src/php-7.0.0/php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

 

# 整合nginx+php
location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $DOCUMENT_ROOT$fastcgi_script_name;
    include        fastcgi_params;
}

 

# 启动php 和nginx 和mysql
/usr/local/php/sbin/php-fpm
/usr/local/nginx/sbin/nginx
service mysqld restart game over!!!

 

 

编译安装PHP时候可能没有libmcrypt库:

centos 6下yum安装mcrypt libmcrypt支持库

使用第三方源实现yum安装,推荐使用RPMforge,在centos下配置该yum源,配置后即可尝试yum install libmcrypt, yum install libmcrypt-devel, yum install mcrypt-devel 安装该库。本人没有实际操作,不确定具体该包的包名。因为如果使用该库,就没必要手工编译php了,直接yum安装好了。配置RPMforge如下

rpm -ivh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
yum clean all
yum makecache

  

posted @ 2018-07-19 14:02  zhuzhipeng  阅读(587)  评论(0编辑  收藏  举报