Linux下yum安装Nginx
1、Centos6系统库中默认是没有nginx的rpn包的,所以我们需要先更新下rpm依赖库
(1):使用yum安装nginx,安装nginx库
rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
(2):使用下面命令安装nginx
yum -y install nginx
(3):启动nginx
service nginx start #centos6
或
systemctl start nginx.service #centos7
(4):防火墙允许通过80端口
vim /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Thu Dec 28 19:47:19 2017
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [21691:949300]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
(5):重启防火墙
service iptables restart
(6):访问 localhost:80