【问题标题】:Google Cloud Platform Apache WebServer says "Site Can't Be Reached"谷歌云平台 Apache WebServer 显示“无法访问站点”
【发布时间】:2017-01-23 01:41:09
【问题描述】:

我是使用 Google Cloud Platform 的新手,我正在尝试托管一个非常简单的静态网站。我完全关注了 Google 的 tutorial for running a basic apache webserver,但是,当我点击我网站的外部 IP 时,我被带到一个页面,上面写着“无法访问此网站。<my site's IP address> 意外关闭了连接ERR_CONNECTION_CLOSED

自从创建虚拟机后,我运行了以下命令:

  • sudo apt-get update && sudo apt-get install apache2 -y
  • echo '<!doctype html><html><body><h1>Hello World!</h1></body></html>' | sudo tee /var/www/html/index.html

我还跑了ping <site IP address> 并看到了表格的行

PING <IP address> 56(84) bytes of data.

64 bytes from <IP address>: icmp_seq=1 ttl=76 time=0.746 ms

我已确保我的 VM 上的防火墙设置已设置为允许 HTTP 和 HTTPS 流量。

为什么我看不到应该在我的站点上托管的简单 Hello World 页面?我需要手动启动apache吗?我试过了,但没有成功。

(我的虚拟机使用 Debian 8 作为启动映像)

更新

应以下用户的要求,我运行了sudo service apache2 status,但得到了以下响应:

apache2.service - LSB: Apache2 web server Loaded: loaded (/etc/init.d/apache2) Drop-In: /lib/systemd/system/apache2.service.d └─forking.conf Active: active (running) since Mon 2017-01-23 01:27:44 UTC; 11h ago CGroup: /system.slice/apache2.service ├─2570 /usr/sbin/apache2 -k start ├─2573 /usr/sbin/apache2 -k start └─2574 /usr/sbin/apache2 -k start

运行sudo service apache2 start 似乎没有做任何事情。

【问题讨论】:

    标签: linux debian apache2 google-cloud-platform google-compute-engine


    【解决方案1】:
    service apache2 status
    

    service apache2 start
    

    您是否在 VM 上选中了允许 HTTP 的复选框?

    【讨论】:

    • 是的,我在原帖中说过。我添加了关于运行您建议的命令时发生的情况的更新。
    【解决方案2】:

    你能telnet到你服务器的80端口吗?试试下面的命令:

    telnet your-server-ip 80
    

    如果上述命令不起作用,那么很可能是防火墙阻止了端口 80。您的服务器上是否运行了第二个防火墙,例如 iptables?。

    【讨论】:

      【解决方案3】:

      您需要为 apache 启用 SSL。

      (重要的是在站点可用文件夹中的 ssl 配置文件的启用站点的文件夹中创建一个系统链接),这将使其运行,但您需要修改 ssl 密钥/证书的东西(检查出证书机器人)

      这是一个指南:https://hallard.me/enable-ssl-for-apache-server-in-5-minutes/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-01
        • 2020-07-16
        • 1970-01-01
        • 2020-03-03
        • 2020-08-30
        • 2019-05-26
        • 1970-01-01
        • 2017-10-06
        相关资源
        最近更新 更多