zoukankan      html  css  js  c++  java
  • Centos 下安装 Nginx(新)

    今天重新实践了下 CentOS 7.6 下安装 Nginx,总结了一条更直接并简单的方式

    从官方获取写入 nginx.repo 的方式

    从官网查看文档,获取 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
    

    将上面内容保存到文件 /etc/yum.repos.d/nginx.repo

    运行 yum

    运行 yum 安装命令,系统自动选择合适的仓库配置安装不出意外的话将会选择 nginx-stable 的配置

    yum install nginx
    

    将 nginx 设置为默认启动

    成功安装后,运行 systemctl 命令,将 nginx 设置为系统运行时自动启动,如有需要运行其它 systemctl 命令

    systemctl enable nginx
    
    # 控制台显示结果如下(centos8为例)
    Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service -> /usr/lib/systemd/system/nginx.service.
    

    其它 systemctl 命令

    systemctl is-enabled *.service #查询服务是否开机启动
    systemctl enable *.service #开机运行服务
    systemctl disable *.service #取消开机运行
    systemctl start *.service #启动服务
    systemctl stop *.service #停止服务
    systemctl restart *.service #重启服务
    systemctl reload *.service #重新加载服务配置文件
    systemctl status *.service #查询服务运行状态
    systemctl --failed #显示启动失败的服务
    systemctl list-units --type=service 查看所有已启动的服务
    
  • 相关阅读:
    复利计算单元测试-软件工程
    实验一 操作系统
    <构建之法>前三章读后感—软件工程
    复利计算总结-软件工程
    实验0-操作系统
    复利计算1.0~2.0~3.0~4.0-软件工程(网页版)
    典型用户与场景
    0608场景(用户故事) 任务
    构建之法读后感+学习和诚信
    0603团队变化+sprint第二个冲刺
  • 原文地址:https://www.cnblogs.com/cinlap/p/11795025.html
Copyright © 2011-2022 走看看