php7.1.5+源码安装,源码编译安装 PHP 7.1.5 + nginx 1.12.0

使用

1、准备安装

先安装 epel-release 源,解决部分依赖包找不到的问题,接着使用最快的源地址生成缓存,然后安装依赖包:

yum install -y epel-release

yum makecache fast

yum install -y gcc gcc-c++ perl libpng-devel libjpeg-devel libwebp-devel libXpm-devel libtiff-devel libxml2-devel libcurl-devel libmcrypt-devel fontconfig-devel freetype-devel libzip-devel bzip2-devel gmp-devel readline-devel recode-devel GeoIP-devel bison re2c

为了让 PHP 和 Nginx 更高效的运行,完善的编译下去,这里指定安装了几个最新版的相关库。

# 下载并解压 libiconv

cd /tmp

curl -O --retry 3 https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz

tar -zxf libiconv-1.15.tar.gz

# 编译

cd libiconv-1.15

./configure --prefix=/usr/local/libiconv

make -j && make install

# 增加到动态链接库:

echo '/usr/local/libiconv/lib' >> /etc/ld.so.conf.d/custom-libs.conf

ldconfig

# 下载并解压 pcre

cd /tmp

curl -O --retry 3 https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz

tar -zxf pcre-8.40.tar.gz

# 编译

cd pcre-8.40

./configure --prefix=/usr/local/pcre

make -j && make install

# 增加到动态链接库

echo '/usr/local/pcre/lib' >> /etc/ld.so.conf.d/custom-libs.conf

ldconfig

# 下载并解压 zlib

cd /tmp

curl -O --retry 3 http://zlib.net/zlib-1.2.11.tar.gz

tar -zxf zlib-1.2.11.tar.gz

# 编译

cd zlib-1.2.11

./configure --prefix=/usr/local/zlib

make -j && make install

# 增加到动态链接库

echo '/usr/local/zlib/lib' >> /etc/ld.so.conf.d/custom-libs.conf

ldconfig

# 下载并解压 libgd

cd /tmp

curl -O --retry 3 -L https://github.com/libgd/libgd/releases/download/gd-2.2.4/libgd-2.2.4.tar.gz

tar -zxf libgd-2.2.4.tar.gz

# 编译

cd libgd-2.2.4

./configure \

--prefix=/usr/local/libgd \

--with-libiconv-prefix=/usr/local/libiconv \

--with-zlib=/usr/local/zlib \

--with-jpeg=/usr \

--with-png=/usr \

--with-webp=/usr \

--with-xpm=/usr \

--with-freetype=/usr \

--with-fontconfig=/usr \

--with-tiff=/usr

make -j && make install

# 增加到动态链接库

echo '/usr/local/libgd/lib' >> /etc/ld.so.conf.d/custom-libs.conf

ldconfig

# 下载并解压 openssl

cd /tmp

curl -O --retry 3 https://www.openssl.org/source/openssl-1.0.2k.tar.gz

tar -zxf openssl-1.0.2k.tar.gz

# 编译

cd openssl-1.0.2k

./config --prefix=/usr/local/openssl -fPIC

make -j && make install

3、安装 PHP

# 下载并解压 php

cd /tmp

curl -O --retry 3 http://cn2.php.net/distributions/php-7.1.5.tar.gz

tar -zxf php-7.1.5.tar.gz

# 编译

cd php-7.1.5

./configure \

--prefix=/usr/local/php71 \

--sysconfdir=/etc/php71 \

--with-config-file-path=/etc/php71 \

--with-config-file-scan-dir=/etc/php71/php-fpm.d \

--with-fpm-user=www \

--with-fpm-group=www \

--with-curl \

--with-mhash \

--with-mcrypt \

--with-gd \

--with-gmp \

--with-bz2 \

--with-recode \

--with-readline \

--with-gettext \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-openssl=/usr/local/openssl \

--with-openssl-dir=/usr/local/openssl \

--with-pcre-regex=/usr/local/pcre \

--with-pcre-dir=/usr/local/pcre \

--with-zlib=/usr/local/zlib \

--with-zlib-dir=/usr/local/zlib \

--with-iconv-dir=/usr/local/libiconv \

--with-libxml-dir=/usr \

--with-libzip=/usr \

--with-gd=/usr/local/libgd \

--with-jpeg-dir=/usr \

--with-png-dir=/usr \

--with-webp-dir=/usr \

--with-xpm-dir=/usr \

--with-freetype-dir=/usr \

--enable-fpm \

--enable-ftp \

--enable-gd-native-ttf \

--enable-gd-jis-conv \

--enable-calendar \

--enable-exif \

--enable-pcntl \

--enable-soap \

--enable-shmop \

--enable-sysvmsg \

--enable-sysvsem \

--enable-sysvshm \

--enable-wddx \

--enable-inline-optimization \

--enable-bcmath \

--enable-mbstring \

--enable-mbregex \

--enable-re2c-cgoto \

--enable-xml \

--enable-mysqlnd \

--enable-embedded-mysqli \

--enable-opcache \

--disable-fileinfo \

--disable-debug

make -j && make install

# 增加软链接

ln -sf /usr/local/php71/bin/php /usr/bin/php

ln -sf /usr/local/php71/bin/phpize /usr/bin/phpize

ln -sf /usr/local/php71/sbin/php-fpm /usr/bin/php-fpm

# 复制 php.ini

cp -v php.ini-production /etc/php71/php.ini

4、安装 Nginx

# 下载并解压 nginx

cd /tmp

curl -O --retry 3 http://nginx.org/download/nginx-1.12.0.tar.gz

tar -zxf nginx-1.12.0.tar.gz

# 创建缓存目录

mkdir -p /var/cache/nginx12

# 编译

cd nginx-1.12.0

./configure \

--prefix=/usr/local/nginx12 \

--conf-path=/etc/nginx12/nginx.conf \

--error-log-path=/var/log/nginx12/error.log \

--http-log-path=/var/log/nginx12/access.log \

--pid-path=/var/run/nginx12.pid \

--lock-path=/var/run/nginx12.lock \

--http-client-body-temp-path=/var/cache/nginx12/client_temp \

--http-proxy-temp-path=/var/cache/nginx12/proxy_temp \

--http-fastcgi-temp-path=/var/cache/nginx12/fastcgi_temp \

--http-uwsgi-temp-path=/var/cache/nginx12/uwsgi_temp \

--http-scgi-temp-path=/var/cache/nginx12/scgi_temp \

--user=www \

--group=www \

--with-threads \

--with-file-aio \

--with-http_ssl_module \

--with-http_v2_module \

--with-http_realip_module \

--with-http_addition_module \

--with-http_geoip_module \

--with-http_sub_module \

--with-http_dav_module \

--with-http_flv_module \

--with-http_mp4_module \

--with-http_gunzip_module \

--with-http_gzip_static_module \

--with-http_auth_request_module \

--with-http_random_index_module \

--with-http_secure_link_module \

--with-http_degradation_module \

--with-http_slice_module \

--with-http_stub_status_module \

--with-mail \

--with-mail_ssl_module \

--with-stream \

--with-stream_ssl_module \

--with-stream_realip_module \

--with-stream_geoip_module \

--with-stream_ssl_preread_module \

--with-compat \

--with-pcre-jit \

--with-pcre=/usr/local/src/pcre-8.40 \

--with-zlib=/usr/local/src/zlib-1.2.11 \

--with-openssl=/usr/local/src/openssl-1.0.2k

make -j && make install

# 增加软链接

ln -sf /usr/local/nginx12/sbin/nginx /usr/bin/nginx

配置

PHP 的安装目录在 /usr/local/php71,配置目录在 /etc/php71

将 /etc/php71/php-fpm.conf.default 复制一份为 /etc/php71/php-fpm.conf 用着默认的 php-fpm 配置文件

如果要增加独立的站点配置,可以在 /etc/php71/php-fpm.d 中创建新的 .conf 为后缀的文件,可以参考 LNMP::php-fpm.d

Nginx 的安装目录在 /usr/local/nginx12,配置目录在 /etc/nginx12,Nginx 的配置可以参考 LNMP::nginx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值