【问题标题】:Not able to access Apache virtual host from other machines on my local network无法从本地网络上的其他机器访问 Apache 虚拟主机
【发布时间】:2017-12-15 01:05:27
【问题描述】:

我无法从网络中的另一台计算机连接到 mysite.com。几个相关的配置文件如下所示。

我的apache2.config

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

NameVirtualHost *:80
ServerName 157.50.13.131
Include /etc/apache2/sites-available/*.conf

我的/etc/hosts

127.0.0.1   localhost
127.0.1.1   ashwin-HP-Notebook
127.0.0.1   mysite.com

The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

我的虚拟主机配置文件(/etc/apache2/sites-available/mysite.conf):

<VirtualHost *:80>
 ServerAdmin webmaster@localhost
 ServerName mysite.com

 DocumentRoot /home/ashwin/mysite
 <Directory /home/ashwin/mysite/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
 </Directory>

 ErrorLog /var/log/apache2/mysite/error.log
 LogLevel warn

 CustomLog /var/log/apache2/mysite/access.log combined

</VirtualHost>

当我从局域网中的系统尝试 192.168.0.100/mysite.com 我得到在此服务器上找不到请求的 URL/mysite.com

为什么这不起作用?

【问题讨论】:

  • 您是否收到错误消息?是什么?
  • 我没有收到任何错误,服务器正在运行。但是当我尝试使用 mysite.com 从网络中的另一个系统访问它时,它只会显示“无法访问此站点”

标签: apache ubuntu


【解决方案1】:

您需要更新客户端计算机上的 hosts 文件,网络服务器的 hosts 文件不会充当您网络上其他系统的 DNS 解析器

# /etc/hosts

192.168.0.100    mysite.com

将其添加到客户端的主机文件后,您应该能够从客户端上的浏览器访问 mysite.com

【讨论】:

    猜你喜欢
    • 2021-05-14
    • 2016-04-27
    • 2012-08-04
    • 2023-03-29
    • 1970-01-01
    • 2011-05-13
    • 2011-10-11
    • 1970-01-01
    • 2018-06-26
    相关资源
    最近更新 更多