1.因为yum源中没有Nginx,需要新增加一个yum源,创建一个nginx.repode 文件
[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
2.把下面的复制到文件中保存
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
3.查询配置yum源
[root@localhost ~]# yum list |grep nginx
4.显示这样则配置成功
collectd-nginx.x86_64 4.10.9-5.el6 epel
munin-nginx.noarch 2.0.63-1.el6 epel
nginx.x86_64 1:1.20.2-1.el7.ngx nginx
nginx-all-modules.noarch 1.10.3-1.el6 epel
nginx-debug.x86_64 1:1.8.0-1.el7.ngx nginx
nginx-debuginfo.x86_64 1:1.20.2-1.el7.ngx nginx
nginx-filesystem.noarch 1.10.3-1.el6 epel
nginx-mod-http-geoip.x86_64 1.10.3-1.el6 epel
nginx-mod-http-image-filter.x86_64 1.10.3-1.el6 epel
nginx-mod-http-perl.x86_64 1.10.3-1.el6 epel
nginx-mod-http-xslt-filter.x86_64 1.10.3-1.el6 epel
nginx-mod-mail.x86_64 1.10.3-1.el6 epel
nginx-mod-stream.x86_64 1.10.3-1.el6 epel
nginx-module-geoip.x86_64 1:1.20.2-1.el7.ngx nginx
nginx-module-geoip-debuginfo.x86_64 1:1.20.2-1.el7.ngx nginx
nginx-module-image-filter.x86_64 1:1.20.2-1.el7.ngx nginx
nginx-module-image-filter-debuginfo.x86_64
1:1.20.2-1.el7.ngx nginx
nginx-module-njs.x86_64 1:1.20.2+0.7.2-1.el7.ngx ngin
..........
5.执行命令显示这样,就可以直接下载nginx
[root@localhost ~]# yum install nginx
开启nginx
[root@localhost ~]# systemctl start nginx
查询nginx状态
[root@localhost ~]# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since 二 2022-02-08 16:27:08 CST; 10s ago