一、关闭selinux: $ vi /etc/selinux/config
改为disabled.
然后重启服务器。
二、安装Nginx: $ yum -y install nginx
如果出现:No package nginx available
参考:https://www.cnblogs.com/maxwell-xu/p/8000458.html
使用:$ rpm -qa | grep nginx
查看nginx是否成功安装.
启动nginx:$ systemctl start nginx
使Nginx在系统引导时自动启动:$ systemctl enable nginx.
检测nginx的当前状态:$ systemctl status nginx
检测firewalld(CentOS7中防火墙从iptables变为firewalld)状态:$ systemctl status firewalld.
如果firewalld没有启用那么需要将其启用。
打开端口80:$ firewall-cmd --zone=public --add-port=80/tcp --permanent
重启防火墙:$ systemctl restart firewalld.
如果想想在Nginx上启用HTTPS,那么还需要代开443端口:
$:firewall-cmd --zone=public --add-port=443/tcp --permanent
使用:$ netstat -lntp 查看端口是否被分配给了Nginx.
使用:$curl 127.0.0.1:80看能否访问。
使用其它机器的浏览器访问:http:ip
原文:https://www.cnblogs.com/gufengchen/p/12038981.html