开发者社区> 问答> 正文

通过修改本地的hosts,文件可以访问自己电脑的WEB服务器吗?

我windows 配置hosts文件添加 dev.aidaogo.com
linux 的hosts 文件同样修改添加 dev.aidaogo.com

情况大致描述:
selinux 和防火墙都已经关闭了

       /bin/systemctl  iptables
       Unknown operation 'iptables'.
       setenforce 0
windows ping dev.aidaogo.com 也是可以ping同的

linux wget dev.aidaogo.com 可以正常下载

netstat -nat
tcp6 0 0 :::80 :::* LISTEN

相关的apache配置

ServerName localhost:80

<Directory />

AllowOverride none
Require all denied
</Directory>

<Directory "/var/www">

AllowOverride None
#Allow open access:
Require all granted
</Directory>

<VirtualHost *:80>

ServerAdmin aidaogo
DocumentRoot /home/www/aidaogo/www
ServerName dev.aidaogo.com
ServerAlias aidaogo
ErrorLog logs/dev.aidaogo.com-error_log
CustomLog logs/dev.aidaogo.com-access_log common
<Directory "/home/www/aidaogo/www">

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

展开
收起
a123456678 2016-06-27 15:32:22 4514 0
2 条回答
写回答
取消 提交回答
  • 旺旺:nectar2。

    您好,

    您这里提到有两个系统,Windows和Linux,那您的Web站点是放在Linux系统里吗?

    您的Linux系统的IP地址是什么呢?

    从上边的netstat命令结果来看,是否您的Web端口仅监听ipv6的地址?

    2019-07-17 19:47:45
    赞同 展开评论 打赏
  • 可以的,
    hosts
    127.0.0.1 www.test.com

    apache conf

    <VirtualHost 127.0.0.1>
        DocumentRoot "D:/web/www"
        ServerName www.test.com
        <Directory "D:/web/www">
            Options FollowSymLinks Indexes
            AllowOverride All
            Order deny,allow
            Allow from 127.0.0.1
            Deny from all
            Require all granted
        </Directory>
    </VirtualHost>
    2019-07-17 19:47:45
    赞同 展开评论 打赏
问答标签:
问答地址:
相关产品:
问答排行榜
最热
最新

相关电子书

更多
Web应用系统性能优化 立即下载
高性能Web架构之缓存体系 立即下载
PWA:移动Web的现在与未来 立即下载