当前位置:   article > 正文

centos7下nginx的安装与升级_centos7升级nginx1.16.1版本到最新

centos7升级nginx1.16.1版本到最新

一、环境准备

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)
  • 1
  • 2

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
  • 1
  • 2
  • 3

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

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

二、安装nginx-1.16.1

1.安装nginx依赖包

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

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
  • 1
  • 2
  • 3
  • 4

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

三、升级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
  • 1
  • 2
  • 3
  • 4

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/151043
推荐阅读
相关标签
  

闽ICP备14008679号