Linux学习总结(22)——CentOS7.2安装Nginx

一、使用Yum安装(推荐)

使用Yum安装是推荐的方式,整体的流程非常的简单,也不容易出错,如果不需要什么特殊配置,建议使用Yum尽进行安装。

1、安装epel-release源并进行安装

1
2
3
yuminstall epel-release
yum update
yuminstall nginx

2、执行相关的应用操作

1
2
3
4
5
systemctl start nginx#启动
systemctl stop nginx#停止
systemctl restart nginx#重启
systemctl status nginx#查看运行状态
systemctlenable nginx #开机启动

3、设置防火墙

在启动完以后可能无法通过IP访问,需要进一步设置防火墙

1
2
3
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

至此,安装完毕。

参考文章:https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7

原文地址:https://www.cnblogs.com/zhanghaiyang/p/7212688.html