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