在 ubuntu 18.04 上安装 Apache2 的问题

在 ubuntu 18.04 上安装 Apache2 的问题

我是一个新的 Linux 用户,我正在尝试安装 Apache2,但是当我输入此命令时

systemctl status apache2.service

我收到这个错误

● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Mon 2018-10-01 15:48:12 -03; 31s ago

out 01 15:48:12 lorena apachectl[23938]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set
out 01 15:48:12 lorena apachectl[23938]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
out 01 15:48:12 lorena apachectl[23938]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
out 01 15:48:12 lorena apachectl[23938]: no listening sockets available, shutting down
out 01 15:48:12 lorena apachectl[23938]: AH00015: Unable to open logs
out 01 15:48:12 lorena apachectl[23938]: Action 'start' failed.
out 01 15:48:12 lorena apachectl[23938]: The Apache error log may have more information.
out 01 15:48:12 lorena systemd[1]: apache2.service: Control process exited, code=exited status=1
out 01 15:48:12 lorena systemd[1]: apache2.service: Failed with result 'exit-code'.
out 01 15:48:12 lorena systemd[1]: Failed to start The Apache HTTP Server.

我该如何修复它?我只是为了使用 rancid 而安装的。

答案1

在两个地方更改 apache 的端口:

  1. /etc/apache2/ports.conf, 和
  2. /etc/apache2/sites-available/000-default.conf

你需要修改(1)行:

Listen 80

Listen 8080

对于(2),

<VirtualHost *:80>

<VirtualHost *:8080>

然后使用 重新启动 apache sudo systemctl restart apache2,注意我8080在这里使用,您可以使用任何其他端口。

另请注意:

端口号 0 到 1024 为特权服务保留,并指定为知名端口。此端口号列表在 RFC 1700 中指定。

端口号范围从 0 到 65535,但只有端口号 0 到 1023 被保留用于特权服务并指定为知名端口。以下知名端口号列表指定服务器进程用作其联系端口的端口。

1      TCP Port Service Multiplexer (TCPMUX)
5      Remote Job Entry (RJE)
7      ECHO
18     Message Send Protocol (MSP)
20     FTP -- Data
21     FTP -- Control
22     SSH Remote Login Protocol
23     Telnet
25     Simple Mail Transfer Protocol (SMTP)
29     MSG ICP
37     Time
42     Host Name Server (Nameserv)
43     WhoIs
49     Login Host Protocol (Login)
53     Domain Name System (DNS)
69     Trivial File Transfer Protocol (TFTP)
70     Gopher Services
79     Finger
80     HTTP
103    X.400 Standard
108    SNA Gateway Access Server
109    POP2
110    POP3
115    Simple File Transfer Protocol (SFTP)
118    SQL Services
119    Newsgroup (NNTP)
137    NetBIOS Name Service
139    NetBIOS Datagram Service
143    Interim Mail Access Protocol (IMAP)
150    NetBIOS Session Service
156    SQL Server
161    SNMP
179    Border Gateway Protocol (BGP)
190    Gateway Access Control Protocol (GACP)
194    Internet Relay Chat (IRC)
197    Directory Location Service (DLS)
389    Lightweight Directory Access Protocol (LDAP)
396    Novell Netware over IP
443    HTTPS
444    Simple Network Paging Protocol (SNPP)
445    Microsoft-DS
458    Apple QuickTime
546    DHCP Client
547    DHCP Server
563    SNEWS
569    MSN
1080   Socks

知名端口范围是 0 到 1023。注册端口为 1024 至 49151。动态端口(也称为私有端口)为 49152 至 65535。

这里了解更多信息。

来源:https://www.webopedia.com/quick_ref/portnumbers.asp

相关内容