这篇文章主要介绍“CentOS下安装Nginx实例分析”,在日常操作中,相信很多人在CentOS下安装Nginx实例分析问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”CentOS下安装Nginx实例分析”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
安装环境:linux 服务器 centos 7.3、root 权限
1、install the prerequisites:
sudo yum install yum-utils
2、to set up the yum repository, create the file named /etc/yum.repos.d/Nginx.repo with the following contents:
(注意替换 os 版本:$releasever,如 centos 版本是 7,就替换成 7)
命令:
vim /etc/yum.repos.d/Nginx.repo
设置 Nginx 的 yum 源:
[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
输入vim命令 :wq 保存并退出
3、to install Nginx, run the following command:
sudo yum install Nginx
中途会输入 y 确认安装
4、when prompted to accept the gpg key, verify that the fingerprint matches 573b fd6b 3d8f bc64 1079 a6ab abf5 bd82 7bd9 bf62, and if so, accept it.
最后会输出 fingerprint,如果和上面红色部分匹配,再输入 y 确认
5、启动 | 停止 | 重启 Nginx:
# 启动 systemctl start Nginx.service # 停止 systemctl stop Nginx.service # 重启 systemctl restart Nginx.service
6、查看 Nginx 所有安装位置:
rpm 是 linux 的 rpm 包管理工具,-q 代表询问模式,-l 代表返回列表
rpm -ql Nginx
/etc/Nginx/conf.d /etc/Nginx/conf.d/default.conf
到此,关于“CentOS下安装Nginx实例分析”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注编程之家网站,小编会继续努力为大家带来更多实用的文章!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。