(转)Centos7 yum 源安装nginx

转:https://www.cnblogs.com/fuhai0815/p/8522868.html

一、建立nginx源

vim /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

二、安装

yum -y install nginx

三、启动

systemctl start nginx

加入开机启动项:systemctl enable nginx

四、配防火墙

vi /etc/sysconfig/iptables   添加下面内容
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允许80端口通过防火墙) 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT(mysql端口  允许3306端口通过防火墙)
然后重启防火墙:service iptables restart

配置文件:/etc/nginx/nginx.conf
默认配置文件:/etc/nginx/conf.d/default.conf
默认网页目录:/usr/share/nginx/html
原文地址:https://www.cnblogs.com/wangle1001986/p/9726904.html