Apache 虚拟主机的奇怪问题

发布于 2024-07-26 18:58:51 字数 2360 浏览 8 评论 0原文

我最近在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

风吹过旳痕迹 2024-08-02 18:58:51

尝试:

NameVirtualHost 127.0.0.1:80

在您的 httpd.conf 中。 我的配置文件包含一条注释,指出应使用端口说明符。

Try:

NameVirtualHost 127.0.0.1:80

In your httpd.conf. My config file includes a comment stating a port-specifier should be used.

静赏你的温柔 2024-08-02 18:58:51

VirtualHostNameVirtualHost 指令应具有 IP 地址和端口:

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80> 
# 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>

The VirtualHost and NameVirtualHost directives should have IP addresses and ports:

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80> 
# 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>
楠木可依 2024-08-02 18:58:51

尝试过 NameVirtualHost 127.0.0.1:80 但它没有有任何区别! 唯一有效的服务器是 localhostmydomain
我想知道除了在 hosts 文件中声明每个虚拟主机的服务器名称之外,是否还需要做一些其他事情。

Tried NameVirtualHost 127.0.0.1:80 but it doesn't make any difference! The only servers that work are localhost and mydomain.
I wonder whether I need to do something more than just declare the server name of each virtual host in the hosts file.

百思不得你姐 2024-08-02 18:58:51

尝试向主机添加端口声明。 例如:

<VirtualHost mydomain:80>
DocumentRoot "C:/Users/Moukasp/django/mysite"
ServerName mydomain
</VirtualHost>

Try adding a port declaration to the hosts. For example:

<VirtualHost mydomain:80>
DocumentRoot "C:/Users/Moukasp/django/mysite"
ServerName mydomain
</VirtualHost>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文