栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

【Centos7 yum在线安装Nginx】

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【Centos7 yum在线安装Nginx】

Centos7 安装nginx

今天在学习nginx安装的时候对着视频安装的可就是服务一直起不来 ,
使用systemctl start nginx 提示如下:
nginx: [alert] could not open error log file: open() “/usr/local/nginx/logs/error.log” failed (2: No such file or directory)
2022/05/10 18:59:52 [emerg] 82492#0: open() “/usr/local/nginx/logs/access.log” failed (2: No such file or directory)

等等还有其他的错误。
于是乎,爱钻研的我就去互联网寻找真理的答案。
找了 一下午几乎块崩溃。又卸载了重装,说什么环境不行之类的。
于是乎到晚上了我找到了一篇博客
然后很多还是手工安装的,不太方便直到找到这个博客使用yum安装的。我立马尝试了一下 !欣喜若狂 (破音。。。)
首先去nginx的官网里面是有提供相应的版本的安装使用的;具体点击:nginx官网
http://nginx.org/en/linux_packages.html#RHEL-CentOS
根据你的linux版本选择对应的使用说明
yum-untils
sudo yum install yum-untils -y
安装好工具
进入 /etc/yum.repos/nginx.repos
vi /etc/yum.repos/nginx.repos

粘贴内容如下:
[nginx-stable]

name=nginx stable repo
baseurl=http://nginx.org/packages/centos/ r e l e a s e v e r / releasever/ 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/ r e l e a s e v e r / releasever/ releasever/basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

按ESC ,SHIFT键,输入:wq保存

然后使用yum进行在线安装
sudo yum install nginx -y
安装完毕!
接下来就是验证一下是否安装成功。
systemctl start nginx 开启nginx的服务
systemct status nginx.service 用来查看nginx的服务


running表示成功了,如果是红色的则表示失败了 。
这里我们用浏览器打开访问一下看看。 输入127.0.0.1 访问网页

这样就完成了nginx的安装。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/882157.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号