為什麼 Apache 運行在連接埠 8080 而不是連接埠 80?

為什麼 Apache 運行在連接埠 8080 而不是連接埠 80?

我很困惑為什麼 Apache 在連接埠 80 上沒有回應...

$ wget http://localhost:80  
--2014-05-06 15:32:44--  http://localhost/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused.

....但是 8080 後...

$ wget http://localhost:8080
--2014-05-06 15:32:38--  http://localhost:8080/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 177 [text/html]
Saving to: ‘index.html’

100%[=================================================>] 177 --.-K/s   in 0s

2014-05-06 15:32:38 (16,4 MB/s) - ‘index.html’ saved [177/177]

在輸出中看不到太多阿帕契2ctl:

$ apache2ctl -t -D DUMP_VHOSTS
VirtualHost configuration:
*:80 is a NameVirtualHost
   default server localhost (/etc/apache2/sites-enabled/000-default.conf:1)
   port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1)
   port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1)

然而,網路統計確認連接埠:

$ sudo netstat -anp | grep :8080
tcp6       0      0 :::8080        :::*       LISTEN      5353/apache2

作為喬爾問這裡是ports.conf

$ sudo cat /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default

Listen 8080

<IfModule ssl_module>
    Listen 443
</IfModule>

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

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
# NameVirtualHost *:8800
Listen 8800

答案1

為什麼 Apache 運行在連接埠 8080 而不是連接埠 80?

apache 經常配置為偵聽該連接埠的常見原因是進程需要在 root 帳戶下運行或被授予特定權限才能偵聽低於且1024當然包括 port 的TCP 連接埠80

使用更高的非特權連接埠號碼允許在常規帳戶下執行 apache,而無需任何特定配置。

8080是一個易於記憶的替代品80

答案2

Listen設定檔中指令的值是多少/etc/apache2/ports.conf

你的顯示為 8080 和 8800,而不是 80,這就是你得到這些結果的原因。

相關內容