apache - 无法从本地网络上的其他机器访问 Apache 虚拟主机

标签 apache ubuntu

我无法连接到 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

为什么这不起作用?

最佳答案

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

# /etc/hosts

192.168.0.100    mysite.com

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

关于apache - 无法从本地网络上的其他机器访问 Apache 虚拟主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47812009/

相关文章:

apache - Docker 错误 : Cannot create container for service web: invalid mode

bash - 如何从 linux 终端读取 8 位 ascii

python - Django Apache : Target WSGI Script Cannot Be Loaded as Python Module

linux - Apache + SSL 错误 336027900

C++文件输出奇怪的数字,部分代码没有运行

linux - 在所有子目录中运行 Hunspell

django - gunicorn:错误:参数--error-logfile/--log-file:预期一个参数

python - 在 Ubuntu 上的 Python 3 中使用 Pip 并导入包

java - 如何避免并发数据库查询的大延迟?

python - Django、mod_wsgi、 Apache : Internal server error