一、安装依赖包

yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

  依赖包说明:

1、编译依赖 gcc 环境,所以需要:gcc gcc-c++;

2、PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库,所以需要:pcre pcre-devel ;

3、zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库,所以需要:zlib zlib-devel ;

4、OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库,所以需要:openssl openssl-devel ;

二、从官网下载安装包

wget https://nginx.org/download/nginx-1.16.0.tar.gz

三、解压并安装

tar zxvf nginx-1.16..tar.gz
cd nginx-1.16.
./configure --prefix=/usr/local/nginx
make && make install

四、测试安装是否成功

[root@localhost ~]# nginx -V
nginx version: nginx/1.16.
built by gcc 4.8. (Red Hat 4.8.-) (GCC)
configure arguments: --prefix=/usr/local/nginx

五、启动nginx服务

cd /usr/local/nginx/sbin
./nginx

六、验证服务是否启动成功

[root@localhost sbin]# netstat -ntlp | grep nginx
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx: master

七、添加nginx服务

vi /lib/systemd/system/nginx.service

  将以下内容插入:

[Unit]
Description=nginx
After=network.target [Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true [Install]
WantedBy=multi-user.target

八、以服务的方式启动nginx

pkill nginx
systemctl start nginx

九、查看服务是否启动

[root@localhost sbin]# systemctl status nginx
● nginx.service - nginx
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Mon -- :: EDT; 18min ago
Process: ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=/SUCCESS)
Main PID: (nginx)
Tasks:
Memory: .0K
CGroup: /system.slice/nginx.service
├─ nginx: master process /usr/local/nginx/sbin/nginx
└─ nginx: worker process Apr :: localhost.localdomain systemd[]: Starting nginx...
Apr :: localhost.localdomain systemd[]: Started nginx.
[root@localhost sbin]# netstat -ntlp | grep nginx
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx: master p

十、配置nginx服务自动启动

[root@localhost sbin]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

centos7 编译安装nginx1.16.0( 完整版 )的更多相关文章

  1. CentOS7 编译安装 nginx-1.10.0

    对于NGINX 支持epoll模型 epoll模型的优点 定义: epoll是Linux内核为处理大批句柄而作改进的poll,是Linux下多路复用IO接口select/poll的增强版本,它能显著的 ...

  2. centos7下编译安装nginx-1.16.0

    一.下载nginx源码 http://nginx.org/en/download.html 如:nginx-1.16.0.tar.gz 二.创建用户和组,并解压 groupadd www userad ...

  3. centos6.5安装nginx1.16.0

    参考:   centos7 编译安装nginx1.16.0( 完整版 ) https://blog.csdn.net/weixin_37773766/article/details/80290939  ...

  4. CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14

    准备篇: CentOS 7.0系统安装配置图解教程 http://www.osyunwei.com/archives/7829.html 一.配置防火墙,开启80端口.3306端口 CentOS 7. ...

  5. CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13

    CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.132013-10-24 15:31:12标签:服务器 防火墙 file 配置文件 written 一.配置好I ...

  6. CentOS7编译安装Nginx-1.8.1和编译参数

    CentOS7编译安装Nginx-1.8.1和编译参数 Web服务器Nginx    LNMP是一组众所周知的Web网站服务器架构环境,即由Linux+Nginx+MySQL+PHP(MySQL有时也 ...

  7. CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13+博客系统WordPress3.3.2

    说明: 操作系统:CentOS 6.2 32位 系统安装教程:CentOS 6.2安装(超级详细图解教程): http://www.osyunwei.com/archives/1537.html 准备 ...

  8. CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14方法分享

    一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...

  9. Centos7.5源码安装nginx-1.16.0

    安装nginx的依赖包(pcre-devel openssl-devel) yum install -y gcc gcc-c++ make pcre pcre-devel zlib zlib-deve ...

随机推荐

  1. 枚举类型与字符串ConvertEnumToString

    枚举类型与字符串添加字典互转ConvertEnumToString using UnityEngine; using System.Collections; using UnityEngine.UI; ...

  2. (转)Linux 系统性能分析工具图解读(一、二)

    Linux 系统性能分析工具图解读(一.二) 原文:http://oilbeater.com/linux/2014/09/08/linux-performance-tools.html 最近看了 Br ...

  3. (转) Linux Shell经典实例解析

    原文:http://blog.csdn.net/yonggeit/article/details/72779955 该篇博客作为对之前Linux Shell常用技巧和高级技巧系列博客的总结,将以Ora ...

  4. BFC --- Block Formatting Context --- 块级格式化上下文

    虽然知道块级格式化上下文是什么东西,但要我把这个东西给说清楚,还真的不是一件容易的事儿,所以这篇文章我就要说说清楚到底什么使传说中的BFC,即块级格式化上下文. 一.BFC的通俗理解 通俗的理解 -- ...

  5. Navicat Premium v12.0.23.0 破解教程x86,x64通用,手动破解

    教程来源于:吾爱破解网站 ----------更新线----------- 2018.01.23 Navicat Premium v12.0.23.0 测试破解依然有效 ----------更新线-- ...

  6. Java入门系列-06-运算符

    这篇文章为你搞懂2个问题 java 中的常用运算符有哪些?如何使用? 这些运算符的运算优先级是怎样的? 算数运算符 明显是做数学运算的,包括以下符号: + 加法运算 敲一敲: public class ...

  7. Html-知识总结

    1.Html概述 1.1什么是Html Html:超文本标记语言(hyperText Markup Language) “超文本”加上指页面内可以包含图片,链接等非文字内容. “标记”就是使用标签的方 ...

  8. Nodejs介绍及npm工具使用

    一.Nodejs介绍 Nodejs英文网:https://nodejs.org/en/ Nodejs中文网:http://nodejs.cn/ Node.js 是一个基于 Chrome V8 引擎的 ...

  9. Bootstrap导航栏navbar源码分析

    1.本文目地:分析bootstrap导航栏及其响应式的实现方式,提升自身css水平 先贴一个bootstrap的导航栏模板 http://v3.bootcss.com/examples/navbar- ...

  10. Iscrool下拉刷新

    简易下拉刷新 css样式: *{ margin: 0px; padding: 0px; } #wrapper{ width: 100%; height: 150px; border: 1px soli ...