centos7下nginx的安装与升级

该文章详细介绍了在CentOS7系统上,如何使用清华大学和阿里云的开源镜像站下载nginx安装包,然后进行nginx的安装,包括设置环境、安装依赖、配置编译和启动服务。接着,文章演示了如何无缝升级nginx至1.17.6版本,包括编译、替换旧版本和验证新版本的功能。
摘要由CSDN通过智能技术生成

一、环境准备

1.centos7系统
清华大学开源镜像站:https://mirrors.tuna.tsinghua.edu.cn/
阿里云镜像站:https://developer.aliyun.com/mirror/

[root@nginx-server ~]# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)

2.nginx安装包准备
nginx官网:http://nginx.org/

[root@nginx-server ~]# ls lnmp_soft/nginx-1.*
lnmp_soft/nginx-1.16.1.tar.gz
lnmp_soft/nginx-1.17.6.tar.gz

3.清空防火墙配置、关闭selinux

[root@nginx-server ~]# iptables -F
[root@nginx-server ~]# setenforce 0

二、安装nginx-1.16.1

1.安装nginx依赖包

[root@nginx-server ~]# yum -y install gcc pcre-devel openssl-devel

2.解压nginx包

[root@nginx-server lnmp_soft]# tar -xf nginx-1.16.1.tar.gz 
[root@nginx-server lnmp_soft]# cd nginx-1.16.1/
[root@nginx-server nginx-1.16.1]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src

3.编译、安装nginx
注意:一定要在安装包内编译安装

[root@nginx-server nginx-1.16.1]# ./configure \
--prefix=/usr/local/nginx \  #指定安装目录
--user=nginx \	#指定账户名称
--group=nginx \ #指定组名称
--with-http_ssl_module	#支持加密功能
[root@nginx-server nginx-1.16.1]# make && make install

4.启动nginx

[root@nginx-server ~]# /usr/local/nginx/sbin/nginx
[root@nginx-server ~]# ps aux | grep nginx
root      13948  0.0  0.0  45968  3260 ?        S    14:57   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody    13949  0.0  0.0  46412  1876 ?        S    14:57   0:00 nginx: worker process
root      14043  0.0  0.0 112808   968 pts/0    S+   15:17   0:00 grep --color=auto nginx
[root@nginx-server ~]# ss -tanulp | grep nginx
tcp    LISTEN     0      128       *:80                    *:*                   users:(("nginx",pid=13949,fd=6),("nginx",pid=13948,fd=6))
[root@nginx-server ~]# /usr/local/nginx/sbin/nginx -V	#查看版本
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --with-http_ssl_module

三、升级nginx

1.解压软件包

[root@nginx-server lnmp_soft]# tar -xf nginx-1.17.6.tar.gz
[root@nginx-server lnmp_soft]# cd nginx-1.17.6/
[root@nginx-server nginx-1.17.6]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src

2.升级nginx
注意:一定要在安装包内编译

[root@nginx-server nginx-1.17.6]# ./configure --with-http_ssl_module
[root@nginx-server nginx-1.17.6]# make
[root@nginx-server nginx-1.17.6]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
[root@nginx-server nginx-1.17.6]# cp objs/nginx /usr/local/nginx/sbin/
[root@nginx-server nginx-1.17.6]# make upgrade
[root@nginx-server ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.17.6
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --with-http_ssl_module
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值