First check
nignx -t
And then view
PS -ef | grep nginx
If the above are not the problem and that is a firewall issue
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
————————————————
Centos7 off the firewall and can not access the nginx
centos7 nginx started successfully but can not access https://blog.csdn.net/qq_39719302/article/details/102780363
By default, Centos7 Firewall is turned on, if you do not stop him, you start the installation of nginx, nginx is unable to access services.
So it is necessary to do it
1, start nginx
Before you start to look at it does not start to see through all ports linux command to see if there 80
netstat -ntlp
If not, the command to start
启动:systemctl start nginx
停止:systemctl stop nginx
重启:systemctl restart nginx
2, set the start nginx open
sudo chkconfig nginx on
3, built-in firewall close Centos Firewall
systemctl stop firewalld.service #停止firewall
4, prohibiting Firewall next start
systemctl disable firewalld.service #禁止firewall开机启动
Other commands
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service 在开机时启用一个服务:systemctl enable firewalld.service 在开机时禁用一个服务:systemctl disable firewalld.service 查看服务是否开机启动:systemctl is-enabled firewalld.service;echo $? 查看已启动的服务列表:systemctl list-unit-files|grep enabled
Centos 7 firewall command:
View already open ports:
firewall-cmd --list-ports
Open port
firewall-cmd --zone=public --add-port=80/tcp --permanent
Command Meaning:
-zone # Scope
-add-port = 80 / tcp # Add port, the format is: port / protocol
-permanent # permanent, this parameter does not restart after failure
Restart the firewall
firewall-cmd --reload #重启firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动 firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
Below that the difference between the lower and the default firewall CentOS7 6
CentOS 7 firewall is used by default as a firewall, it must be reset using iptables
1, directly off the firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service # prohibit firewall boot
2, provided iptables service
yum -y install iptables-services
If you want to modify the firewall configuration, such as increasing the firewall port 3306
vi /etc/sysconfig/iptables
Add Rule
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
Save and exit
systemctl restart iptables.service # reboot the firewall configuration to take effect
systemctl enable iptables.service # firewall settings boot
Finally, you can reboot the system settings to take effect.
systemctl start iptables.service # turn on the firewall
systemctl stop iptables.service # turn off the firewall to resolve the host can not access the site while back CentOS virtual machine in the virtual machine upload good CentOS6.2, and with good apache + php + mysql, but the machine is not accessible. He has gone to toss.
Details are as follows
1. 本机能ping通虚拟机
2. 虚拟机也能ping通本机
3.虚拟机能访问自己的web
4.本机无法访问虚拟机的web
Later found to be a firewall to port 80 blocked sake.
Check the port 80 is not blocked by a firewall server, you can command: telnet server_ip 80 to test.
Solutions are as follows:
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
Then save:
/etc/rc.d/init.d/iptables save
Restart the firewall
/etc/init.d/iptables restart
CentOS firewall turned off, shut down its services to:
查看CentOS防火墙信息:/etc/init.d/iptables status
关闭CentOS防火墙服务:/etc/init.d/iptables stop