简体   繁体   English

无法访问 CentOS httpd

[英]Couldn't access CentOS httpd

I have been using Ubuntu, just recently started to work on Centos (CentOS Linux release 7.1.1503 (Core)) running in VMplayer on my desktop (Ubuntu).我一直在使用 Ubuntu,最近才开始在我的桌面 (Ubuntu) 上的 VMplayer 中运行 Centos(CentOS Linux 版本 7.1.1503(核心))。

  • Branch new CentOS installation.分支新的 CentOS 安装。
  • installed httpd (using "yum")安装了 httpd(使用“yum”)
  • for some reason, httpd didn't start automatically, I ran "service httpd start" and it started according to "netstat -antp".出于某种原因,httpd 没有自动启动,我运行了“service httpd start”,它根据“netstat -antp”启动。

     [root@localhost ~]# netstat -antp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1161/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1620/master tcp 0 0 10.0.0.19:22 10.0.0.7:20383 ESTABLISHED 2421/sshd: root@pts tcp6 0 0 :::80 :::* LISTEN 2453/httpd tcp6 0 0 :::22 :::* LISTEN 1161/sshd tcp6 0 0 ::1:25 :::* LISTEN 1620/master
  • I can access the http server locally ( curl http://localhost within the CentOs command line)我可以在本地访问 http 服务器(在 CentOs 命令行中curl http://localhost

  • when I tried access httpd from the host curl http://172.16.13.143/ , it refused the TCP connection.当我尝试从主机curl http://172.16.13.143/访问 httpd 时,它拒绝了 TCP 连接。 I was able to to ssh into it, it works ok for ssh ssh root@172.16.13.143 .我能够 ssh 进入它,它适用于 ssh ssh root@172.16.13.143
  • I have stopped iptables service iptables stop我已经停止 iptables service iptables stop
  • SELinux is turned off according to getenforce command.根据getenforce命令关闭 SELinux。

I just need to do a quick test on the web interface but I can't.我只需要在 Web 界面上进行快速测试,但我不能。 Really need some help.真的需要一些帮助。 Thanks.谢谢。

Packages installed on RHEL/CentOS/Fedora systems aren't supposed to start any services automatically (because maybe you're not ready to expose your service to the world until after you've configured it).安装在 RHEL/CentOS/Fedora 系统上的软件包不应该自动启动任何服务(因为在配置它之前,您可能还没有准备好向世界公开您的服务)。

Running service httpd start will start the service temporarily, but it won't start next time you boot.运行service httpd start会暂时启动该服务,但下次启动时不会启动。 You want systemctl enable httpd to enable the service to start automatically when you boot your system.您希望systemctl enable httpd使服务在您启动系统时自动启动。

You could check if the firewall is actually disabled.您可以检查防火墙是否真的被禁用。 Run iptables -S to see the current ruleset.运行iptables -S以查看当前规则集。 The default iptables configuration typically allows only ssh and nothing else.默认的 iptables 配置通常只允许ssh而不允许其他任何东西。

Update更新

Your system is probably running firewalld to manage the firewall.您的系统可能正在运行firewalld来管理防火墙。 Try service firewalld stop .尝试service firewalld stop

You can run systemctl disable firewalld to prevent it from starting next time your system boots.您可以运行systemctl disable firewalld以防止它在您的系统下次启动时启动。

-- CentOS 7 -- CentOS 7

add the following to '/etc/httpd/conf/httpd.conf'将以下内容添加到“/etc/httpd/conf/httpd.conf”

Replace:
Listen 80

With:
Listen 0.0.0.0:80

this will disable ipv6 and enable ipv4这将禁用 ipv6 并启用 ipv4

To check this type:要检查此类型:

netstat -an | grep -i tcp | grep -i listen

restart apache service重启apache服务

systemctl restart httpd.service

Also, enable firewall to access port 80另外,启用防火墙访问端口 80

firewall-cmd --permanent --add-service=http
firewall-cmd --reload

Did you do a iptables -L to make sure no firewall is running?您是否执行了iptables -L以确保没有防火墙正在运行?

Execute following command to make sure no other firewalls is running too执行以下命令以确保没有其他防火墙也在运行

ps -ef

"80" is being listened so something is blocking your connection looks like正在收听“80”,因此某些内容正在阻止您的连接看起来像

In a standard installation, CentOS 7 is set to prevent traffic to Apache.在标准安装中,CentOS 7 设置为阻止到 Apache 的流量。

add the ports to your firewall:将端口添加到防火墙:

for http:对于 http:

sudo firewall-cmd --permanent --add-port=80/tcp 

for https:对于 https:

sudo firewall-cmd --permanent --add-port=443/tcp 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM