在运行 apache 服务器时无法访问 http://localhost:80 [英] Can't get access to http://localhost:80 on running apache server

查看:172
本文介绍了在运行 apache 服务器时无法访问 http://localhost:80的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 ubuntu 14.04 中运行 apache 服务器时,我在浏览器中收到 此网页不可用"curl: (7) 无法连接到本地主机端口 80:连接被拒绝" 使用 $ curl localhost.此外我可以连接到 127. * .* .* (e.g. 127.0.0.2) - 仅适用于 127.0.0.1

On running apache server in ubuntu 14.04 I get "This webpage is not available" in browser or "curl: (7) Failed to connect to localhost port 80: Connection refused" using $ curl localhost. Besides I can connect to 127. * . * . * (e.g. 127.0.0.2) - doesn't work only 127.0.0.1

/etc/hosts

 127.0.0.1  localhost
 127.0.1.1  al-ubuntu
 # The following lines are desirable for IPv6 capable hosts 
 ::1     ip6-localhost ip6-loopback
 fe00::0 ip6-localnet
 ff00::0 ip6-mcastprefix
 ff02::1 ip6-allnodes
 ff02::2 ip6-allrouters

ports.conf

Listen 80

<IfModule ssl_module>
   Listen 443
</IfModule>

<IfModule mod_gnutls.c>
  Listen 443
</IfModule>

当我更改端口时,例如Listen 82 然后我可以连接到 localhost:82 或 127.0.0.1:82

When I change port e.g. Listen 82 then I can connect to localhost:82 or 127.0.0.1:82

没有任何进程使用端口 80,除了 apache2:

<代码>$sudo netstat -tulpn |grep 80

=> tcp6 0 0 :::80 ::::* LISTEN 7127/apache2

在/var/log/apache2/中有三个文件:

access.log, error.log and other_vhosts_access.log

重启apache2时: $ tail -f error.log

 [Thu Feb 19 16:03:19.570066 2015] [mpm_prefork:notice] [pid 1285] AH00169: 
 caught SIGTERM, shutting down
 [Thu Feb 19 16:03:20.673519 2015] [mpm_prefork:notice] [pid 3454] AH00163:   
 Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.6 configured -- resuming normal  
 operations
 [Thu Feb 19 16:03:20.674355 2015] [core:notice] [pid 3454] AH00094: Command line: '/usr/sbin/apache2'

当在所有日志文件中连接到本地主机时 - 什么都没有.

When connecting to localhost in all log files - nothing.

我在其他 ubuntu14.04 系统上安装了 apache,一切正常.

I installed apache on other ubuntu14.04 system and all works.

80端口阻塞的原因,你知道是什么问题吗?

What cause blocking port 80, do you know in what the problem is?

推荐答案

我遇到了同样的问题.在我的 apache 的 httpd.conf 文件中,我有

I had the same problem. In my apache's httpd.conf file, I had

Listen 198.166.2.1:8000

然后我把它改成:

Listen 8000

它既适用于本地主机又适用于 IP 地址.

and it worked both with localhost and with the ip address.

这篇关于在运行 apache 服务器时无法访问 http://localhost:80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆