dqtok88424 2014-04-29 14:57
浏览 37

windows7中Apache上的虚拟主机

As i tried to configure my virtual host on apache(xampp) in windows7 - x64.

I put something like this,

NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/projects/mysite/public"
   ServerName www.mysite.com 
   ErrorLog "logs/www.mysite.com-error.log"
   CustomLog "logs/www.mysite.com-access.log" common
</VirtualHost>

And in my hosts file (C:\Windows\System32\drivers\etc\hosts) i put something like this,

127.0.0.1       localhost
127.0.0.1       mysite.com

And i run it on the browser,

http://www.mysite.com -

Server not found

Firefox can't find the server at www.mysite.com.

Do i missed something to configure? Any ideas..

  • 写回答

2条回答 默认 最新

  • doumi1884 2014-04-29 15:20
    关注

    Your hosts file needs to be

        127.0.0.1       localhost
        127.0.0.1       mysite.com
        127.0.0.1       www.mysite.com
    

    Because mysite.com and www.mysite.com are not the same. I recommend add ServerAlias into your vhost.conf and change ServerName

        NameVirtualHost *:80
    
        <VirtualHost *:80>
           DocumentRoot "C:/xampp/htdocs/projects/mysite/public"
           ServerName mysite.com
           ServerAlias www.mysite.com 
           ErrorLog "logs/www.mysite.com-error.log"
           CustomLog "logs/www.mysite.com-access.log" common
        </VirtualHost>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题