麦克斯仇
Think different
159
文章
27970
阅读
首页
INDEX
文章
ARTICLE
关于
ABOUT
CentOS7安装Nginx(yum源)
创建日期:
2019/05/15
修改日期:
2023/06/05
Linux
Nginx
官方安装教程:[http://nginx.org/en/linux_packages.html#RHEL-CentOS](http://nginx.org/en/linux_packages.html#RHEL-CentOS) > 说明 使用 `yum` 源方式安装后,软件的文件位置不统一,且不可定制插件,推荐[源码包方式安装](https://maxqiu.com/article/detail/15) # 配置 `yum` 源 安装 `yum` 工具 ```bash yum -y install yum-utils ``` 新建 `yum` 源文件 ```bash vim /etc/yum.repos.d/nginx.repo ``` 添加如下内容并保存 ```conf [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 [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 ``` 注:(可选项)选择主线版,即 `mainline`(建议用稳定版,即默认的 `stable` ) ```bash yum-config-manager --enable nginx-mainline ``` # 安装 ```bash yum -y install nginx ``` > 注:yum在国外,可能无法下载,或者下载速度慢 # 设置开机自启 ```bash # 开启开机自启 systemctl enable nginx.service # 关闭开机自启 systemctl disable nginx.service ``` # 启动与关闭 ``` # 启动 systemctl start nginx.service # 关闭 systemctl stop nginx.service # 查看状态 systemctl status nginx.service ```
7
全部评论