0

我正在尝试使用 xampp 在 Windows 中设置两个虚拟主机。从我读过的内容来看,必须更改 Windows 主机文件和 xampp 的 httpd-vhosts.conf 文件。

主机文件:

127.0.0.1       gholizadeh
127.0.0.1       doostr
127.0.0.1       localhost

虚拟主机文件:

    NameVirtualHost *:80

<VirtualHost gholizadeh>
    DocumentRoot "E:\xampp\htdocs\lowkey\pappa"
    ServerName gholizadeh.se
    ServerAlias www.gholizadeh.se
    <Directory "E:\xampp\htdocs\lowkey\pappa">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost doostr>
    DocumentRoot "E:\xampp\htdocs\lowkey"
    ServerName doostr.com
    ServerAlias www.doostr.com
    <Directory "E:\xampp\htdocs\lowkey">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost localhost>
    DocumentRoot "E:\xampp"
    ServerName localhost
    <Directory "E:\xampp">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

但我在访问这些文件时遇到问题。当我从我自己的 LAN 尝试它时,我会被提示到 xampp 站点,并且当尝试从外部网络进入它时访问被拒绝。我究竟做错了什么?

4

1 回答 1

0

VirtualHost命令错了。像这样使用它:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName gholizadeh.se
    ServerAlias www.gholizadeh.se
    DocumentRoot "E:\xampp\htdocs\lowkey\pappa"
    <Directory "E:\xampp\htdocs\lowkey\pappa">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName doostr.com
    ServerAlias www.doostr.com
    DocumentRoot "E:\xampp\htdocs\lowkey"
    <Directory "E:\xampp\htdocs\lowkey">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "E:\xampp"
    <Directory "E:\xampp">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

还有一些事情:*您应该ServerAdmin向每个主机添加一个 *主机文件中的条目仅用于内部调试目的,我假设?

附带说明:您不打算从这个 MS-Windows 系统在互联网上提供真实的网页,是吗?

于 2013-04-16T08:13:42.570 回答