安装 Apache 后无法连接到本地主机

安装 Apache 后无法连接到本地主机

安装 Apache 后, 我无法连接到本地主机。我检查了以下 URL:https//localhosthttps//127.0.1.1https//127.0.1.1

以下是我收到的日志消息和我的IP地址信息:

avinash@ubuntu:/etc/init.d$ sudo service apache2 restart
[sudo] password for avinash: 
 * Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName


avinash@ubuntu:/etc/init.d$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:54:d4:d1  
          inet addr:192.168.56.130  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe54:d4d1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14746 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7681 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:17657949 (17.6 MB)  TX bytes:749463 (749.4 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:172 errors:0 dropped:0 overruns:0 frame:0
          TX packets:172 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:9920 (9.9 KB)  TX bytes:9920 (9.9 KB)

答案1

尝试使用 http:// 作为 localhost 而不是 https://

http://localhost

https:// 用于安全服务器,默认本地 IP 地址是 127.0.0.1 而不是 127.0.1.1

答案2

使用以下 URL:

http://localhost

同时将以下行添加到您的apache2.conf文件位于/etc/apache2

ServerName localhost 

以上将抑制警告

waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

相关内容