在 WAMP 2.4.9 服务器上将本地主机设置为其他所需名称会出现 404 错误

Setting-up localhost to other desired name on WAMP 2.4.9 server gets 404 Error

我想将我的本地主机服务器重命名为其他名称,但是我遇到了 404 错误。我已按照如何设置的步骤进行操作,但仍然出现错误。我想知道出了什么问题。我将提供完成的更改。

c:\Windows\System32\Drivers\Etc\hosts.file

127.0.0.1   localhost
127.0.0.1   bluescript.com.ph

::89    localhost
::89    bluescript.com.ph

c:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhost.conf 我在文件中添加了第三个主机

<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 *:80>
  ServerName bluescript.com.ph
  DocumentRoot "c:/wamp/www/bluescript/"
  <Directory "c:/wamp/www/bluescript/">
      Options +Indexes +FollowSymLinks +MultiViews
      AllowOverride All
      Require local
  </Directory>
</VirtualHost>

在 httpd.conf 下,我确实将端口更改为 8989,因为 Skype 将使用端口 80

ServerName localhost:8989

#Listen 12.34.56.78:8989
Listen 0.0.0.0:8989
Listen [::0]:8989

我已经重新启动 WAMP 并重新打开网络浏览器并输入 url: http://bluescript.com.ph 并收到错误:HTTP 错误 404。找不到请求的资源。我哪里错了?

1) 删除这些指向不存在文件夹的虚拟(示例)虚拟主机

<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>

2) 如果您必须为 Apache 使用非标准端口号,那么该端口号也需要在虚拟主机上。

您还应该为本地主机添加一个虚拟主机

<VirtualHost *:8989>
    ServerName localhost
    DocumentRoot c:/wamp/www
    <Directory  "c:/wamp/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

<VirtualHost *:8989>
  ServerName bluescript.com.ph
  DocumentRoot "c:/wamp/www/bluescript/"
  <Directory "c:/wamp/www/bluescript/">
      Options +Indexes +FollowSymLinks +MultiViews
      AllowOverride All
      Require local
  </Directory>
</VirtualHost>

还记得删除 httpd.conf 中的注释以激活 httpd-vhosts.conf 文件

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Now restart Apache

当然,这意味着您必须在所有网址上使用非标准端口号。喜欢

http://bluescript.com.ph:8989

3) 这在您的主机文件中也是错误的!此文件中未使用端口号,因此

::89    localhost
::89    bluescript.com.ph

应该是

::1    localhost
::1    bluescript.com.ph

此更改后重新启动,或从命令 window 启动 "As Adminitrator" do

net stop dnscache
net start dnscache