当前位置: 首页 > news >正文

源码编译安装 PHP 7.1.5 + nginx 1.12.0

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

使用

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

2、安装 libiconvpcrezliblibgdopenssl

为了让 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

转载于:https://my.oschina.net/zhiqiangwang/blog/1546839

相关文章:

  • 微信分享JS-SDK
  • 独家 | 环境大数据的应用案例及前景
  • P4165 [SCOI2007]组队
  • 跨域问题
  • laraval+node.js实现websocket
  • PowerShell 脚本执行策略
  • MSDN SmartCast更改下载步骤
  • QT之二维绘图:场景,图元,视图
  • DockOne微信分享( 八十八):PPTV聚力传媒的Docker与DevOps
  • VM中ubuntu虚拟机共享文件夹,mnt下面没有hgfs
  • 软件測试的类型、方法以及策略------一张图搞定
  • 高亮必填字段
  • golang语法学习(一):变量,常量以及数据类型
  • Unity实现刺客信条灯光的思路探究
  • 【webstrom】webstrom打开多个项目,webstrom常用快捷键
  • 【译】JS基础算法脚本:字符串结尾
  • 【跃迁之路】【699天】程序员高效学习方法论探索系列(实验阶段456-2019.1.19)...
  • 10个确保微服务与容器安全的最佳实践
  • Docker: 容器互访的三种方式
  • Java|序列化异常StreamCorruptedException的解决方法
  • JavaScript新鲜事·第5期
  • springMvc学习笔记(2)
  • Terraform入门 - 1. 安装Terraform
  • ucore操作系统实验笔记 - 重新理解中断
  • vue的全局变量和全局拦截请求器
  • 从0搭建SpringBoot的HelloWorld -- Java版本
  • 从0到1:PostCSS 插件开发最佳实践
  • 干货 | 以太坊Mist负责人教你建立无服务器应用
  • 关于使用markdown的方法(引自CSDN教程)
  • 排序(1):冒泡排序
  • 使用 Node.js 的 nodemailer 模块发送邮件(支持 QQ、163 等、支持附件)
  • 使用parted解决大于2T的磁盘分区
  • 适配mpvue平台的的微信小程序日历组件mpvue-calendar
  • 我是如何设计 Upload 上传组件的
  • 翻译 | The Principles of OOD 面向对象设计原则
  • 资深实践篇 | 基于Kubernetes 1.61的Kubernetes Scheduler 调度详解 ...
  • ​如何防止网络攻击?
  • #大学#套接字
  • #调用传感器数据_Flink使用函数之监控传感器温度上升提醒
  • #我与Java虚拟机的故事#连载15:完整阅读的第一本技术书籍
  • $redis-setphp_redis Set命令,php操作Redis Set函数介绍
  • (html5)在移动端input输入搜索项后 输入法下面为什么不想百度那样出现前往? 而我的出现的是换行...
  • (八)光盘的挂载与解挂、挂载CentOS镜像、rpm安装软件详细学习笔记
  • (二)PySpark3:SparkSQL编程
  • (切换多语言)vantUI+vue-i18n进行国际化配置及新增没有的语言包
  • (完整代码)R语言中利用SVM-RFE机器学习算法筛选关键因子
  • (新)网络工程师考点串讲与真题详解
  • (一)VirtualBox安装增强功能
  • .net 4.0 A potentially dangerous Request.Form value was detected from the client 的解决方案
  • .NET Core SkiaSharp 替代 System.Drawing.Common 的一些用法
  • .NET 跨平台图形库 SkiaSharp 基础应用
  • .NET 使用 XPath 来读写 XML 文件
  • @configuration注解_2w字长文给你讲透了配置类为什么要添加 @Configuration注解
  • @DependsOn:解析 Spring 中的依赖关系之艺术
  • @RequestParam,@RequestBody和@PathVariable 区别