【Linux】循序渐进学运维-CentOS7使用yum方式安装nginx(1)

2. To set up the yum repository(添加源)

create the file named /etc/yum.repos.d/nginx.repo with the following contents:


[root@ecs-c13b ~]# vim /etc/yum.repos.d/nginx.repo

[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



安装nginx
1. 查看nginx源是否添加成功

[root@ecs-c13b ~]# yum search nginx

2. 安装并查看

[root@ecs-c13b ~]# yum install nginx

[root@ecs-c13b ~]# rpm -qa | grep nginx

nginx-1.18.0-1.el7.ngx.x86_64

[root@ecs-c13b ~]# 



3. 启动nginx

[root@ecs-c13b ~]# systemctl start nginx

[root@ecs-c13b ~]# systemctl enable nginx

Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

[root@ecs-c13b ~]# systemctl status nginx

● nginx.service - nginx - high performance web server

   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)

   Active: active (running) since Fri 2020-07-31 08:52:55 CST; 15s ago

     Docs: http://nginx.org/en/docs/

 Main PID: 21326 (nginx)

   CGroup: /system.slice/nginx.service

           ├─21326 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

           └─21327 nginx: worker process



Jul 31 08:52:55 ecs-c13b systemd[1]: Starting nginx - high performance web server...

Jul 31 08:52:55 ecs-c13b systemd[1]: Started nginx - high performance web server.

[root@ecs-c13b ~]# 



4. 从浏览器端查看

在这里插入图片描述

在这里插入图片描述

我们在网站根目录传一张图片:

[root@ecs-c13b html]# pwd

/usr/share/nginx/html

[root@ecs-c13b html]# ls

50x.html csdn-0731.png index.html

[root@ecs-c13b html]#

重新查看网页:

在这里插入图片描述

总结

nginx的安装相对来说比较简单,使用哪种方式安装都可以,在工作中自由选择。

本文转自 https://zmedu.blog.csdn.net/article/details/107705300,如有侵权,请联系删除。

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以点击这里获取!

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值