Apache 虚拟主机的奇怪问题
我最近在 Windows Vista 计算机上安装了 Apache 1.3.41。 我没有更改 httpd.conf aprart 中的默认设置来尝试设置虚拟主机,如下所示:
在主机文件中添加了一些主机名:
127.0.0.1 localhost
#::1 localhost
127.0.0.1 mysite
127.0.0.1 mydomain
我在 C:/Users/Moukasp/ 中创建了以下文件夹
C:/Users/Moukasp/Apache
C:/Users/Moukasp/django/mysite
然后添加了一些简单的 html 页面在每个文件夹和 c:/Users/Moukasp/pictures
文件夹中,最后,我在 httpd.conf 末尾添加了以下设置:
NameVirtualHost 127.0.0.1
<VirtualHost localhost>
# ServerAdmin [email protected]
DocumentRoot "C:/Users/Moukasp/Apache"
ServerName localhost
Alias "/pics" "c:/users/moukasp/pictures"
Alias "/ap" "C:/Program Files/Apache Group/Apache/htdocs"
Alias "/dj" "C:/Users/Moukasp/django/mysite"
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost mysite>
# ServerAdmin [email protected]
DocumentRoot "C:/Users/Moukasp/django/mysite"
ServerName mysite
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost mydomain>
# ServerAdmin [email protected]
DocumentRoot "C:/Users/Moukasp/django/mysite"
ServerName mydomain
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
因此,url
http://localhost
http://localhost/pics
http://localhost/ap
http://localhost/dj
http://mydomain
工作正常。 但我没有来自 http://mysite
的响应,从设置中可以看出,它与 http://mydomain
位于同一文件夹中。 我尝试了各种名称,但没有任何反应。 每次启动 Apache 服务器时都会读取主机文件。 我什至从主机文件和 httpd.conf
中删除了 mydomain
服务器,以免虚拟主机的数量受到限制,但没有成功。
任何帮助将不胜感激,否则我会发疯的! 确实如此,在让 Apache 与 mod_python for django 一起工作完全失败后,我一直在尝试这个! 我只是希望一步一步能够取得一些成功!
I have recently installed Apache 1.3.41 on a Windows Vista machine. I have not changed the default settings in httpd.conf aprart from trying to setup virtual hosts, as follows:
Added some host names in the hosts file:
127.0.0.1 localhost
#::1 localhost
127.0.0.1 mysite
127.0.0.1 mydomain
I made the following folders in C:/Users/Moukasp/
C:/Users/Moukasp/Apache
C:/Users/Moukasp/django/mysite
Then added some simple html pages in each of those folder and the c:/Users/Moukasp/pictures
folder and, finally, I added the following settings at the end of httpd.conf:
NameVirtualHost 127.0.0.1
<VirtualHost localhost>
# ServerAdmin [email protected]
DocumentRoot "C:/Users/Moukasp/Apache"
ServerName localhost
Alias "/pics" "c:/users/moukasp/pictures"
Alias "/ap" "C:/Program Files/Apache Group/Apache/htdocs"
Alias "/dj" "C:/Users/Moukasp/django/mysite"
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost mysite>
# ServerAdmin [email protected]
DocumentRoot "C:/Users/Moukasp/django/mysite"
ServerName mysite
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost mydomain>
# ServerAdmin [email protected]
DocumentRoot "C:/Users/Moukasp/django/mysite"
ServerName mydomain
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
So, urls
http://localhost
http://localhost/pics
http://localhost/ap
http://localhost/dj
http://mydomain
work fine. But I there's no response from http://mysite
which, as can be seen from the settings, serves from the same folder as http://mydomain
. I have tried various names but no response. The hosts file is being read every time I start the Apache server. I even removed the mydomain
server from the hosts file and the httpd.conf
lest there's a limitation in the number of virtual hosts, but no luck.
Any help would be greatly appreciated, els I go mad! It is true, I have being trying this after complete failure to make Apache work with mod_python for django! I just hoped that a step at a time would lead to some success!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试:
在您的 httpd.conf 中。 我的配置文件包含一条注释,指出应使用端口说明符。
Try:
In your httpd.conf. My config file includes a comment stating a port-specifier should be used.
VirtualHost
和NameVirtualHost
指令应具有 IP 地址和端口:The
VirtualHost
andNameVirtualHost
directives should have IP addresses and ports:尝试过
NameVirtualHost 127.0.0.1:80
但它没有有任何区别! 唯一有效的服务器是localhost
和mydomain
。我想知道除了在
hosts
文件中声明每个虚拟主机的服务器名称之外,是否还需要做一些其他事情。Tried
NameVirtualHost 127.0.0.1:80
but it doesn't make any difference! The only servers that work arelocalhost
andmydomain
.I wonder whether I need to do something more than just declare the server name of each virtual host in the
hosts
file.尝试向主机添加端口声明。 例如:
Try adding a port declaration to the hosts. For example: