Problem description:
The Apache (httpd) installed on CentOS 7 in the virtual machine cannot be accessed from the host when accessing the virtual machine.
Solution:
You can directly run the following command to set tcp port 80 to allow any IP to access.
[root@localhost ~]# iptables -I INPUT -p TCP --dport 80 -j ACCEPT
Then you can access it normally on the host.
Note: You have to re-execute this method after restarting.
If we are just learning to use it ourselves, we can completely turn off the firewall. The specific command (only applicable to CentOS 7) is as follows:
#停止firewall systemctl stop firewalld.service #禁止firewall开机启动 systemctl disable firewalld.service
Recommended tutorial: centos tutorial
The above is the detailed content of What should I do if httpd cannot be accessed under centos?. For more information, please follow other related articles on the PHP Chinese website!