CentOS7 - 安装Nginx

Nginx的安装

  • 点击进入 Ngunx官网下载稳定版本页面
  • 找到 Pre-Built Packages for Stable version,选择与自己系统相关的操作,如 CentOS 7,则选择

    To set up the yum repository for RHEL/CentOS, create the file named /etc/yum.repos.d/nginx.repo with the following contents:
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
    gpgcheck=0
    enabled=1
    Replace “OS” with “rhel” or “centos”, depending on the distribution used, and “OSRELEASE” with “6” or “7”, for 6.x or 7.x versions, respectively.

  • 安装Nginx

[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# vim nginx.repo
# nginx.repo
# 需要对上面的源信息进行更改 OS=>centos   OSRELEASE=>7
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
# 保存退出

# 列出Nginx相关
[root@localhost yum.repos.d]# yum list | grep nginx
# 安装Nginx
[root@localhost yum.repos.d]# yum install nginx
# 查看Nginx版本信息 (小写v)
[root@localhost yum.repos.d]# nginx -v
# 查看Nginx相关参数信息 (大写V)
[root@localhost yum.repos.d]# nginx -V
# 启动Nginx
[root@localhost yum.repos.d]# service nginx start
# 或者
[root@localhost yum.repos.d]# systemctl start nginx.service
# 停止Nginx
[root@localhost yum.repos.d]# service nginx stop
# 或者
[root@localhost yum.repos.d]# systemctl stop nginx.service
# 重启Nginx
[root@localhost yum.repos.d]# service nginx restart
# 或者
[root@localhost yum.repos.d]# systemctl restart nginx.service
# 重载Nginx配置,平滑重启
[root@localhost yum.repos.d]# service nginx reload  
# 或者
[root@localhost yum.repos.d]# systemctl reload nginx.service

转载于:https://www.cnblogs.com/zpsong/p/8447661.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值