0

我之前创建了两个虚拟主机,即 [localhost] 和“phpsite”。昨天我将“phpsite”重命名为“phppages”并添加了一个名为“techsupport.com”的虚拟主机。我在我的 Apache 服务器上使用端口 8088。但是现在我可以使用 [localhost]:8088 和 phpsite:8088 虽然没有名为“phpsite”的虚拟主机,如果我去 techsupport.com:8088 我什么也得不到。

这是我的虚拟主机内容:

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
#    ServerName dummy-host.example.com
#    ServerAlias www.dummy-host.example.com
#    ErrorLog "logs/dummy-host.example.com-error.log"
#    CustomLog "logs/dummy-host.example.com-access.log" common
#</VirtualHost>

#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host2.example.com
#    DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
#    ServerName dummy-host2.example.com
#    ErrorLog "logs/dummy-host2.example.com-error.log"
#    CustomLog "logs/dummy-host2.example.com-access.log" common
#</VirtualHost>

<VirtualHost *:8088>
    ServerAdmin admin@example.com
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ServerAlias www.localhost.com
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
    <Directory "c:/wamp/www">
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 localhost ::1
    </Directory>
</VirtualHost>

<VirtualHost *:8088>
     DocumentRoot "e:/techsupport"
     ServerName techsupport.com
     ServerAlias www.techsupport.com
     ErrorLog "logs/techsupport-error.log"
     CustomLog "logs/techsupport-access.log" common
     <Directory "e:/TechSupport">
         Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Order Deny,Allow
         Deny from all
         Allow from 127.0.0.1 localhost ::1
     </Directory>
</VirtualHost>

<VirtualHost *:8088>
    DocumentRoot "e:/phppages"
    ServerName phppages
    ServerAlias www.phppages.com
    ErrorLog "logs/phppages-error.log"
    CustomLog "logs/phppages-access.log" common
    <Directory "e:/PHPPages">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 localhost ::1
    </Directory>
</VirtualHost>

Apache 的错误日志显示:

[Sun Aug 25 12:50:06.646882 2013] [mpm_winnt:notice] [pid 7936:tid 500] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations
[Sun Aug 25 12:50:06.646882 2013] [mpm_winnt:notice] [pid 7936:tid 500] AH00456: Server built: Feb 22 2013 22:08:37
[Sun Aug 25 12:50:06.646882 2013] [core:notice] [pid 7936:tid 500] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sun Aug 25 12:50:06.647883 2013] [mpm_winnt:notice] [pid 7936:tid 500] AH00418: Parent: Created child process 912
[Sun Aug 25 12:50:07.216263 2013] [mpm_winnt:notice] [pid 912:tid 384] AH00354: Child: Starting 150 worker threads.
[Sun Aug 25 12:51:15.409867 2013] [mpm_winnt:notice] [pid 7936:tid 500] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sun Aug 25 12:51:17.411205 2013] [mpm_winnt:notice] [pid 912:tid 384] AH00364: Child: All worker threads have exited.
[Sun Aug 25 12:51:17.433218 2013] [mpm_winnt:notice] [pid 7936:tid 500] AH00430: Parent: Child process 912 exited successfully.
[Sun Aug 25 12:51:30.206760 2013] [mpm_winnt:notice] [pid 11396:tid 204] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations
[Sun Aug 25 12:51:30.207763 2013] [mpm_winnt:notice] [pid 11396:tid 204] AH00456: Server built: Feb 22 2013 22:08:37
[Sun Aug 25 12:51:30.207763 2013] [core:notice] [pid 11396:tid 204] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sun Aug 25 12:51:30.208763 2013] [mpm_winnt:notice] [pid 11396:tid 204] AH00418: Parent: Created child process 4808
[Sun Aug 25 12:51:30.670070 2013] [mpm_winnt:notice] [pid 4808:tid 384] AH00354: Child: Starting 150 worker threads.
[Sun Aug 25 13:25:30.406049 2013] [mpm_winnt:notice] [pid 11396:tid 204] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sun Aug 25 13:25:32.406924 2013] [mpm_winnt:notice] [pid 4808:tid 384] AH00364: Child: All worker threads have exited.
[Sun Aug 25 13:25:32.423935 2013] [mpm_winnt:notice] [pid 11396:tid 204] AH00430: Parent: Child process 4808 exited successfully.
[Sun Aug 25 13:28:38.706114 2013] [mpm_winnt:notice] [pid 10328:tid 516] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations
[Sun Aug 25 13:28:38.706114 2013] [mpm_winnt:notice] [pid 10328:tid 516] AH00456: Server built: Feb 22 2013 22:08:37
[Sun Aug 25 13:28:38.706114 2013] [core:notice] [pid 10328:tid 516] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sun Aug 25 13:28:38.708114 2013] [mpm_winnt:notice] [pid 10328:tid 516] AH00418: Parent: Created child process 4716
[Sun Aug 25 13:28:39.170423 2013] [mpm_winnt:notice] [pid 4716:tid 380] AH00354: Child: Starting 150 worker threads.
[Sun Aug 25 13:33:14.347584 2013] [mpm_winnt:notice] [pid 10328:tid 516] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sun Aug 25 13:33:16.349839 2013] [mpm_winnt:notice] [pid 4716:tid 380] AH00364: Child: All worker threads have exited.
[Sun Aug 25 13:33:16.369232 2013] [mpm_winnt:notice] [pid 10328:tid 516] AH00430: Parent: Child process 4716 exited successfully.
[Sun Aug 25 13:33:18.445939 2013] [mpm_winnt:notice] [pid 7048:tid 464] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations
[Sun Aug 25 13:33:18.445939 2013] [mpm_winnt:notice] [pid 7048:tid 464] AH00456: Server built: Feb 22 2013 22:08:37
[Sun Aug 25 13:33:18.445939 2013] [core:notice] [pid 7048:tid 464] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sun Aug 25 13:33:18.446940 2013] [mpm_winnt:notice] [pid 7048:tid 464] AH00418: Parent: Created child process 2556
[Sun Aug 25 13:33:18.801179 2013] [mpm_winnt:notice] [pid 2556:tid 324] AH00354: Child: Starting 150 worker threads.
[Sun Aug 25 13:35:23.175992 2013] [mpm_winnt:notice] [pid 7048:tid 464] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sun Aug 25 13:35:25.178255 2013] [mpm_winnt:notice] [pid 2556:tid 324] AH00364: Child: All worker threads have exited.
[Sun Aug 25 13:35:25.197268 2013] [mpm_winnt:notice] [pid 7048:tid 464] AH00430: Parent: Child process 2556 exited successfully.
[Sun Aug 25 13:35:28.224795 2013] [mpm_winnt:notice] [pid 10616:tid 504] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations
[Sun Aug 25 13:35:28.224795 2013] [mpm_winnt:notice] [pid 10616:tid 504] AH00456: Server built: Feb 22 2013 22:08:37
[Sun Aug 25 13:35:28.224795 2013] [core:notice] [pid 10616:tid 504] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sun Aug 25 13:35:28.225792 2013] [mpm_winnt:notice] [pid 10616:tid 504] AH00418: Parent: Created child process 4012
[Sun Aug 25 13:35:28.599042 2013] [mpm_winnt:notice] [pid 4012:tid 324] AH00354: Child: Starting 150 worker threads.
[Sun Aug 25 13:43:03.326392 2013] [mpm_winnt:notice] [pid 10616:tid 504] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sun Aug 25 13:43:07.389104 2013] [mpm_winnt:notice] [pid 4012:tid 324] AH00364: Child: All worker threads have exited.
[Sun Aug 25 13:43:07.404736 2013] [mpm_winnt:notice] [pid 10616:tid 504] AH00430: Parent: Child process 4012 exited successfully.
[Sun Aug 25 13:45:26.908312 2013] [mpm_winnt:notice] [pid 4788:tid 504] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations
[Sun Aug 25 13:45:26.970818 2013] [mpm_winnt:notice] [pid 4788:tid 504] AH00456: Server built: Feb 22 2013 22:08:37
[Sun Aug 25 13:45:26.970818 2013] [core:notice] [pid 4788:tid 504] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sun Aug 25 13:45:26.970818 2013] [mpm_winnt:notice] [pid 4788:tid 504] AH00418: Parent: Created child process 5084
[Sun Aug 25 13:45:27.517719 2013] [mpm_winnt:notice] [pid 5084:tid 384] AH00354: Child: Starting 150 worker threads.

在 httpd.cnf 文件中:

Listen 0.0.0.0:8088

(之前只是听 8088)

Include conf/extra/httpd-vhosts.conf

未注释,因为它应该是。

我现在很无助,已经花了2天时间。请帮忙。

谢谢

4

1 回答 1

1

我之前创建了两个虚拟主机,即 [localhost] 和“phpsite”。昨天我将“phpsite”重命名为“phppages”并添加了一个名为“techsupport.com”的虚拟主机。我在我的 Apache 服务器上使用端口 8088。但是现在我可以使用 [localhost]:8088 和 phpsite:8088 虽然没有名为“phpsite”的虚拟主机,如果我去 techsupport.com:8088 我什么也得不到。

“phppages”不工作而“phpsite”工作的唯一原因可能是因为您在“phpsite”而不是“phppages”的主机文件中有一个DNS条目或条目。要调试它,我将从 ping 它们开始。

ping phppages

ping phpsite

当我们讨论名称解析主题时,您techsupport.com:8088将无法工作,因为已techsupport.com解析到外部站点。如果他们没有对公众开放的 8088 端口,您根本无法在该端口上导航到该站点。但是,如果他们这样做了,那么您将能够浏览他们的页面而不是您的页面。

我不确定 WAMP 如何管理主机名,但首先要检查的是您的 DNS 服务器(如果有的话),否则检查C:\Windows\System32\drivers\etc\hosts.

要进行phppages工作,请将以下几行添加到您的C:\Windows\System32\drivers\etc\hosts

127.0.0.1    phppages    www.phppages.com

# Similarly for techsupport.com and www.techsupport.com
127.0.0.1    techsupport.com    www.techsupport.com

在此之后,您的 phppages 和 techsupport url 应该可以工作了。

注意:当/如果您从主机文件中删除该虚拟主机httpd-vhosts.conf并忘记从主机文件中删除相应的主机名时,将公共 URL 添加到您的主机文件可能会导致混淆,在这种情况下,这些公共 URL 将无法到达正确的目的地。因此,不建议为您的虚拟主机使用公共主机名。

希望这可以帮助。

于 2013-08-25T09:46:50.853 回答