大网数据广告活动
服务器运维问答

EC2 instance has apache2 server installed, but I can't connect to it

· 52CE 我爱测

I have an EC2 instance running Ubuntu 18.04, with apache2 server. I am able to connect to it via PuTTY and via FileZilla and view the server. The server is running, there is the index.html file that's created by apache2 under /va…

问题原文

原帖链接 · pileup · CC BY-SA 4.0

I have an EC2 instance running Ubuntu 18.04, with apache2 server. I am able to connect to it via PuTTY and via FileZilla and view the server. The server is running, there is the index.html file that's created by apache2 under /var/www, but still when I type in my public IPv4 address in the browser, I cannot connect and view the apache2 welcome page (Cannot connect to it)

What may be the cause? Is it possible that it's because I am on free tier and I am already running another EC2 instance? (Which is working fine)

*Edit: I ran the following commands and these are the outputs:

netstat -plunt | grep "443 \|80 "

(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp6 0
0 :::80 :::* LISTEN

curl -I http://localhost

HTTP/1.1 200 OK Date: Mon, 31 Dec 2018 16:39:42 GMT Server: Apache/2.4.29 (Ubuntu) Last-Modified: Mon, 31 Dec 2018 12:54:24 GMT ETag: "2bb4-56f5oe88329x4" Accept-Ranges: bytes Content-Length: 10918 Vary: Accept-Encoding Content-Type: text/html

已采纳解答

原帖链接 · Itai Ganot · CC BY-SA 4.0

When you want to expose a service/port on an EC2 Instance, you need to create a security group which allows connections in that port and attach it to the instance.

So for example, you can create a security group like so:

And when you attach it to the instance, it will allow connections on port 80 from all the world (0.0.0.0/0).

Also, I'd check that the server actually listens on this port, run:

netstat -plunt | grep "443 \|80 "

And to see that the server responds:

curl -I http://localhost

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-12-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。