记录一下华为云ECS弹性服务器 Centos8 指定版本安装Nginx,以备后查。
1、更新一下yum并设置阿里云仓库
下载新的yum源,执行下面两条命令:
> curl https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo > /etc/yum.repos.d/Centos-vault-8.5.2111.repo
> curl https://mirrors.aliyun.com/repo/epel-archive-8.repo > /etc/yum.repos.d/epel-archive-8.repo
然后执行yum -y update 进行更新:
> yum -y update
此时可以执行命令 dnf info Nginx 来查看当前系统的Nginx版本信息
> dnf info Nginx
如果执行dnf info Nginx 报以下错误,则需要把 /etc/yum.repos.d 中不要的 .repo文件删掉
删掉不要的 .repo文件后,在执行 dnf info Nginx 得到如下信息:
> vi /etc/yum.repos.d/Nginx.repo
执行上面这句后,把下面的内容作为Nginx.reop的内容进行粘贴保存
[Nginx-stable] name=Nginx stable repo baseurl=http://Nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://Nginx.org/keys/Nginx_signing.key module_hotfixes=true [Nginx-mainline] name=Nginx mainline repo baseurl=http://Nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://Nginx.org/keys/Nginx_signing.key module_hotfixes=true
3、列出Nginx的所有版本,执行命令 yum list Nginx --showduplicates
> yum list Nginx --showduplicates
结果如下图:
4、安装指定版本的Nginx,我这里使用最新的,执行yum -y install Nginx-1.22.0 命令
> yum -y install Nginx-1.22.0
看到这个表示安装完成,我们查看一下安装目录:
> whereis Nginx
5、启动Nginx
> Nginx
6、Nginx几个操作命令
Nginx #启动 Nginx -s stop #停止Nginx Nginx -s reload #重启Nginx Nginx -c /etc/Nginx/Nginx.conf #使用指定配置文件启动Nginx Nginx -t #检测配置文件是否有错误 Nginx -v #查看版本信息
参考文章:https://www.cnblogs.com/niewd/p/15035272.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。