2017-03-07 4 views
0

Windowsで仮想ホストを作成するには、この手順に従いますが、動作しないため何が問題なのか分かりません。Apache 2.4はhttpd-vhosts.confファイルを無視します

このURLを持つ仮想ホストが必要です:http://local.shop

のhttpd-vhosts.conf

<VirtualHost *:80>  
DocumentRoot "C:/Apache24/htdocs/" 
ServerName localhost 
ServerAlias localhost 
<Directory "C:/Apache24/htdocs/"> 
    AllowOverride All 
</Directory> 

<VirtualHost *:80>  
    DocumentRoot "C:/Apache24/htdocs/shop/" 
    ServerName local.shop 
    ServerAlias local.shop 
    <Directory "C:/Apache24/htdocs/shop/"> 
     AllowOverride All 
    </Directory> 
    ErrorLog "logs/localhost.html-error.log" 
    CustomLog "logs/localhost.html-access.log" common 
</VirtualHost> 

ホスト

127.0.0.1 localhost 
    127.0.0.1 local.shop 

私はhttp://localhostにアクセスしようと務めたページがあるページですon C:/ Apac私はhttp://local.shopにアクセスしようとした場合he24/htdocsに/ショップ/私は次のエラー私が間違っているのは何ERR_NAME_NOT_RESOLVED

んですか?

編集1:私はhttp://localhostに役立ったページにアクセスしようとした場合、私は今にServerAliasディレクティブを削除している

は右ページですが、私はhttp://local.shopにACCESしようとすると、まだ動作しません。私が編集2同じエラーにERR_NAME_NOT_RESOLVED

を持っている: 私は、各ホストに到達しようとする窓から「ピング」コマンドを使用していました。そして私はローカルホストからの応答を取得しなく

local.shop

から enter image description here enter image description here

編集3:私はhttpdの-vhosts.confのlocalhostの私の定義で変更を行った 。私はDocumentRootのを変更しました「C:/ Apache24/htdocsに/ショップ」代わりに私はまだ元のローカルホストからの既定のページを取得し、お店のディレクトリから既定のページを取得する

<VirtualHost *:80>  
    DocumentRoot "C:/Apache24/htdocs/shop" 
    ServerName localhost 
    ServerAlias localhost 
    <Directory "C:/Apache24/htdocs/"> 
     AllowOverride All 
    </Directory> 
</VirtualHost> 

。 Apacheのようにhttpd-vhosts.confファイルを無視するようです。

+0

ない問題を、しかしそれら 'ServerAlias'ディレクティブを削除してください、彼らはそのようにどんな意味がありません。 – arkascha

+0

httpサーバを再起動したときに、httpサーバのエラーログファイルにエントリがありますか? – arkascha

+0

ホスト名 'local.shop'に対するコマンドライン解決の試行は何ですか? – arkascha

答えて

0

Apacheは多分リスニングしますが(vhostsファイルの編集後に再起動した場合)、何も指していません。ホストファイル(C:\ Windows \ System32 \ drivers \ etc \ hostsにあります)を編集し、ドメイン "local.shop"をIPアドレス127.0.0.1に設定する必要があります。管理者権限で開いたメモ帳でそのファイルを編集することができます。それが必要

は次のようなものになります。

# Copyright (c) 1993-2009 Microsoft Corp. 
# 
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows. 
# 
# This file contains the mappings of IP addresses to host names. Each 
# entry should be kept on an individual line. The IP address should 
# be placed in the first column followed by the corresponding host name. 
# The IP address and the host name should be separated by at least one 
# space. 
# 
# Additionally, comments (such as these) may be inserted on individual 
# lines or following the machine name denoted by a '#' symbol. 
# 
# For example: 
# 
#  102.54.94.97  rhino.acme.com   # source server 
#  38.25.63.10  x.acme.com    # x client host 

# localhost name resolution is handled within DNS itself. 
# 127.0.0.1  localhost 
# ::1    localhost 
127.0.0.1 local.shop 
+0

あなたのコメントをありがとうが、私はまだ私のWindowsホストファイル内のドメインlocal.shopをひそかにしています。 –

+0

実際のエラーは "ERR_NAME_NOT_RESOLVED"(つまり、 "私はこのドメインがどのサーバーであるかわかりません)ので、まだApache側にエラーはありません。 –

関連する問題