Home >Operation and Maintenance >Apache >What should I do if I cannot access the web page after apache is started?

What should I do if I cannot access the web page after apache is started?

王林
王林forward
2021-01-27 10:32:5710451browse

What should I do if I cannot access the web page after apache is started?

Foreword:

Apache cannot be accessed after it is started. After investigation, we found that the port was not occupied, so we considered a firewall issue.

(Learning video sharing: Introduction to Programming)

Solution:

First we need to ensure that the remote Linux system has been installed, we use xshell Remote SSH login to the Linux system, we also need to ensure that apache has been installed using yum and other commands, and then we start troubleshooting and analysis

What should I do if I cannot access the web page after apache is started?

In order to be able to access the server remotely For web pages, we first need to ensure that the apache service httpd is running. We use the command to check the status of the corresponding service:

service httpd status

If it is running as shown in the figure, it means that the service has been started, otherwise we need to use the command Pull up the httpd service:

service httpd start

What should I do if I cannot access the web page after apache is started?

Then we need to determine the status of SELinux. SELinux is a security policy service under the Linux system, but due to the complicated settings and the need for system services and The access operation has a great impact. If it is not closed, it may cause some abnormal conditions. Therefore, we need to use the command to determine whether SELinux has been closed:

sestatus

If it is disabled as shown in the figure, it means it has been closed. , otherwise we need to use the command to temporarily close the policy service:

setenforce 0

What should I do if I cannot access the web page after apache is started?

Then we need to determine whether port 80 is occupied by other programs, use the following command to check:

netstat -lnp | grep 80

If port 80 is used by httpd as shown in the picture, it is OK, otherwise we need to make corrections, which will not be detailed here

What should I do if I cannot access the web page after apache is started?

Then we can first check whether the system firewall is turned on. When other services are normal, the inability to access the web page is most likely caused by the incorrect configuration of the firewall. Therefore, we first use the following command to determine the status of the firewall

 service iptables status

If it is as shown in the figure below, it means that the system's firewall is running. In order to do a simple troubleshooting check, we can try to turn off the firewall first, and then turn it on and reconfigure it after confirming that it is a firewall problem.

 service iptables stop

What should I do if I cannot access the web page after apache is started?

What should I do if I cannot access the web page after apache is started?

After I turned off the firewall, I found that I could access it normally. After confirming the root cause, we need to reopen the firewall for system security. Then we need to access the system. The tcp network of port 80 requests firewall configuration. We need to restart the firewall first

 service iptables start

Then enter the command to configure the firewall and view the configured firewall policy

iptables -I INPUT -p TCP --dport 80 -j ACCEPT
service iptables status

After completion, as shown in the figure, The configuration is complete and remote access to the web page on the server is OK

What should I do if I cannot access the web page after apache is started?

Related recommendations: apache tutorial

The above is the detailed content of What should I do if I cannot access the web page after apache is started?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete