6

ここで何が起こっているのかわかりませんが、MAC OS X で MAMP 1.9 を実行しています。私の httpd.conf ファイルでは、DocumentRoot がデフォルトの htdocs パスに設定されています。htdocs フォルダー内に、仮想ホストとして設定するために、いくつかの「サブサイト」を作成しました。指定されたパスにアクセスできますが、最初に設定したパスがデフォルトになっているようです。 .

基本的に、最初に構成した VirtualHost は site1.localhost.com 用でした。それ以来、site2.localhost.com と site3.localhost.com を構成しました。ただし、最後の 2 つのアドレスのいずれかにアクセスすると、常に site1.localhost.com にリダイレクトされるようです。さらに、localhost.com:8888 に移動すると、site1.localhost.com が表示されます。どこで間違いを犯したのかわかりませんが、ここの誰かが問題を解決するのを手伝ってくれることを願っています...ああ、/ etc /に変更を加えた後、Apacheなどを再起動しましたhosts または httpd.conf ファイル。

私のhttpd.confファイル(関連する部分、とにかく...):

#                                                                                                                                                                                                                                                                             
# DocumentRoot: The directory out of which you will serve your                                                                                                                                                                                                                
# documents. By default, all requests are taken from this directory, but                                                                                                                                                                                                      
# symbolic links and aliases may be used to point to other locations.                                                                                                                                                                                                         
#                                                                                                                                                                                                                                                                             
# MAMP DOCUMENT_ROOT !! Don't remove this line !!                                                                                                                                                                                                                             


 DocumentRoot "/Applications/MAMP/htdocs"

#                                                                                                                                                                                                                                                                             
# Note that from this point forward you must specifically allow                                                                                                                                                                                                               
# particular features to be enabled - so if something's not working as                                                                                                                                                                                                        
# you might expect, make sure that you have specifically enabled it                                                                                                                                                                                                           
# below.                                                                                                                                                                                                                                                                      
#                                                                                                                                                                                                                                                                             

#                                                                                                                                                                                                                                                                             
# This should be changed to whatever you set DocumentRoot to.                                                                                                                                                                                                                 
#                                                                                                                                                                                                                                                                             
<Directory "/Applications/MAMP/htdocs">

<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/site1/"
ServerName site1.localhost.com
</VirtualHost>

<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/sub/site2/"
ServerName site2.localhost.com
</VirtualHost>

<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/sub/site3/"
ServerName site3.localhost.com
</VirtualHost>

/etc/hosts ファイルで:

##                                                                                                                                                                                                                                                                            
# Host Database                                                                                                                                                                                                                                                               
#                                                                                                                                                                                                                                                                             
# localhost is used to configure the loopback interface                                                                                                                                                                                                                       
# when the system is booting.  Do not change this entry.                                                                                                                                                                                                                      
##                                                                                                                                                                                                                                                                            
127.0.0.1       localhost
127.0.0.1       site1.localhost.com
127.0.0.1       site2.localhost.com
127.0.0.1       site3.localhost.com
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
4

3 に答える 3

4

httpd.conf ファイルで次の行を見つけて、コメント (#) を削除します。

 # NameVirtualHost * 
于 2010-09-02T22:43:42.810 に答える
0

私はあなたがあなたの答えを得たのを見ることができます。私の場合は十分ではありませんでした。Chords の提案を追加すると、localhost + 他の多くの仮想ホスト (demo.client.com) が MAMP で動作するようになりました。リストの一番上に、localhostを仮想ホストとして追加した場合にのみ機能しました。

NameVirtualHost *:80
<VirtualHost *:80>
  DocumentRoot "/Applications/MAMP/htdocs"
  ServerName localhost
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin me@email.com
  DocumentRoot "/Applications/MAMP/htdocs/clientA/"
  ServerName clientA.local
  ErrorLog "logs/clientA-local-error_log"
  CustomLog "logs/clientA-local-access_log" common
</VirtualHost>
于 2014-03-16T02:00:50.077 に答える
0

MattLeff の回答に加えて、念のため、サーバー エイリアスも追加する必要があります。

ServerAlias www.website.dev

そうしないと、ブラウザが自動的に "http://www" を追加します (そしてそれを非表示にします、rawr!)、環境は自動的に最初の仮想ホストにデフォルト設定されます。

于 2012-09-01T20:52:01.690 に答える