Apache2 localhost无法连接到所需的VirtualHost

Apache2 localhost无法连接到所需的VirtualHost,apache2,ip-address,localhost,virtualhost,Apache2,Ip Address,Localhost,Virtualhost,我的电脑上安装了几个虚拟主机。我想使用my comp的ip地址从不同的PC访问我当前正在使用的站点,但我尝试的每个配置都会将我带到不同的虚拟主机(实际上是我在我的comp上设置的第一个虚拟主机)。如何设置apache virtualhost配置以确保ip地址将我带到我想要的站点 /etc/apache2/sites available/site-i-want-to-show-up-with-ip-address.conf包含: <VirtualHost *:80> ServerAdm

我的电脑上安装了几个虚拟主机。我想使用my comp的ip地址从不同的PC访问我当前正在使用的站点,但我尝试的每个配置都会将我带到不同的虚拟主机(实际上是我在我的comp上设置的第一个虚拟主机)。如何设置apache virtualhost配置以确保ip地址将我带到我想要的站点

/etc/apache2/sites available/site-i-want-to-show-up-with-ip-address.conf包含:

<VirtualHost *:80>
ServerAdmin webmaster@localhost

ServerAlias currentsite.com

DocumentRoot /path/to/root/of/site-i-want-to-show-up
ServerName localhost

ScriptAlias /awstats/ /usr/lib/cgi-bin/

CustomLog /var/log/apache2/current-site-access.log combined
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerAlias theothersite.com
    DocumentRoot /path/to/it
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>

</VirtualHost>

服务器管理员webmaster@localhost
ServerAlias currentsite.com
DocumentRoot/path/to/root/of/site-i-want-to-show-up
服务器名本地主机
ScriptAlias/awstats//usr/lib/cgi-bin/
CustomLog/var/log/apache2/current-site-access.log组合
和/etc/apache2/sites available/site-that-keeps-showing-up.conf包含:

<VirtualHost *:80>
ServerAdmin webmaster@localhost

ServerAlias currentsite.com

DocumentRoot /path/to/root/of/site-i-want-to-show-up
ServerName localhost

ScriptAlias /awstats/ /usr/lib/cgi-bin/

CustomLog /var/log/apache2/current-site-access.log combined
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerAlias theothersite.com
    DocumentRoot /path/to/it
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>

</VirtualHost>

服务器管理员webmaster@localhost
服务器别名theothersite.com
DocumentRoot/path/to/it
选项如下符号链接
不允许超限
我非常感谢任何人的帮助


另外,我对配置web服务器不太了解,我使用教程获得了上述代码。

也在/etc/hosts中添加一个:

127.0.0.1 theothersite.com

1) 在VirtualHosts部分之前,您需要:

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
2) 每个部分都需要一个DocumentRoot和一个ServerName项:

<VirtualHost 172.20.30.50>
DocumentRoot /www/example1
ServerName www.example1.com

# Other directives here ...

</VirtualHost>

DocumentRoot/www/example1
服务器名www.example1.com
#这里的其他指令。。。
确保已打开。然后,从另一台计算机,您需要设置hosts文件,以便在访问这两个域时,它将转到服务器的IP

ip.addr.x.y currentsize.com
ip.addr.x.y theothersite.com
# ip.addr.x.y is the ip of the pc with apache, this file goes on your other pc
如果您想通过IP地址访问,就不能使用基于名称的虚拟主机,要做到这一点,您需要多个IP,并将每个虚拟主机设置为每个IP,如

<VirtualHost ip.addr.x.y:80>
# one of the two IP addresses bound to the pc with apache on it
</VirtualHost>

<VirtualHost ip.addr.x.z:80>
# the other of the two IP addresses bound to the pc with apache on it
</VirtualHost>

#绑定到装有apache的pc的两个IP地址之一
#绑定到装有apache的pc的两个IP地址中的另一个

如果请求未指定名称,它将使用第一个配置的命名虚拟主机。

他正在从另一台电脑访问该站点,如果他使用的是本地电脑上的命名主机,则主机中的此项将是。现在,我获得的(98)地址已在使用中:make_sock:无法绑定到地址[:]:80