一、安装依赖包

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. Linux定时任务与开机自启动脚本(cron与crontab)

    开机自启动脚本 网上常见的脚本开机自启方法是: 假设要自启的脚本位于 /home/user/test.sh 给脚本可执行的权限 sudo chmod +x /home/user/test.sh 将脚本 ...

  2. Linux服务器性能评估与优化--转

    http://www.itlearner.com/article/4553 一.影响Linux服务器性能的因素 1. 操作系统级 Ø       CPU Ø       内存 Ø       磁盘I/ ...

  3. 【VMware&Vritualbox】虚拟机安装windows server2016

    一.下载镜像 参考链接:https://blog.csdn.net/yenange/article/details/52981769 http://blog.sina.com.cn/s/blog_10 ...

  4. 10 个最佳的 Node.js 的 MVC 框架

    补充:http://nokit.org/ https://thinkjs.org/zh-cn/doc/index.html Node.js 是一个基于Chrome JavaScript 运行时建立的一 ...

  5. [DForm]我也来做自定义Winform之另类标题栏重绘

    据说得有楔子 按照惯例,先来几张样例图(注:为了展示窗口阴影效果,截图范围向外扩展了些,各位凭想象吧).                   还要来个序 其实,很多年没写过Winform了,前端时间在 ...

  6. [转]在ASP.NET Core使用Middleware模拟Custom Error Page功能

    本文转自:http://www.cnblogs.com/maxzhang1985/p/5974429.html 阅读目录 一.使用场景 二..NET Core实现 三.源代码 回到目录 一.使用场景 ...

  7. 关于supersocker的数据传输中遇到的问题

    最近在学socket,在使用socket时数据的传输与接口都是byte,所以文本与文件的传输只要对传过来的byte处理好就可以. 但是在supersocket上,我却花费了很长的时间.原因如下: 1. ...

  8. 一分钟学会Git操作流程

    今天整理下公司操作git 流程,尽量用最最简洁的方式整理出来,方便以后有新来的同事学习使用. 我整理的这个Git操作,基本上只需要一分钟,就可以轻松上手啦!!! 一. 拉取提交操作 1.拉取远程代码 ...

  9. sqlServer游标的使用

    USE [PatPD1]GO/****** Object:  UserDefinedFunction [dbo].[fun_GetConditionInner]    Script Date: 201 ...

  10. python之迭代器

    原文 我们已经知道,可以直接作用于for循环的数据类型有以下几种: 一类是集合数据类型,如list.tuple.dict.set.str等: 一类是generator,包括生成器和带yield的gen ...