2

ローカルマシンでwww.my-dev-branch.comのようなものにアクセスした場合に、システム上のファイルを指すようにローカルサーバーを設定するにはどうすればよいですか?例:'c:/wamp/www/www.my-dev -copy.com '

注:私はWAMPを使用しているWindows7を使用しています

4

2 に答える 2

3

通常、この種のことは、C:\ WINDOWS \ SYSTEM32 \ DRIVERS\ETCにあるhostsファイルを操作して行われます。

このような行を追加します

127.0.0.1       www.my-dev-branch.com 

Win7では、このパスは通常のビューから隠されていることに注意してください。
エクスプローラウィンドウのアドレスバーにパスを直接入力する必要があります。
もちろん、管理者権限が必要です。

于 2012-06-01T21:05:03.293 に答える
0

私が探していたものを以下で見つけました:

http://www.infotales.com/seting-up-local-domains-windows-apache-wamp/

Recently had to setup local domains for my php projects. Normally I use http://localhost/project_directory urls for normal project, but for a new project I had to setup few local domains. For existing projects I still need localhost (127.0.0.1) available along local domains like project.localhost.com. Setting up local domains and virtual hosts is easy and I found it worth sharing.
I am using Windows Vista Business with WampServer Version 2.0 installed. This method should also work for standalone apache installation.
First we need to add host entry in windows host. To do this, open file
C:\Windows\System32\drivers\etc\hosts
in some text editor, by using Open With menu from right click.
Note that C: represent your drive where windows is installed, in most cases it will be C: but it can be different.
You will see content smiler to
# Copyright (c) 1993-2006 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
127.0.0.1 localhost
::1 localhost
Now add this line
127.0.0.1 project.localhost.com

at the end. Here you can add any custom domain like projectname.local etc.
The line added tells windows to resolve to local IP when ever this domain name is requested by browser etc. Be sure not to add any live existing domains as they will be resolved to localhost instead of live host.
Now we need to add virtual host entry in Apache server so we can server our project files. For this apache config file which in this case is
C:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf
. Open the file with text editor and find following lines
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
The second line tells conf file to include another configuration file which contains virtual host configurations. The line is commented by default so we have to enable it.
Now remove
#
sign from start of the second line and save file, so the line will look
Include conf/extra/httpd-vhosts.conf
.
Now open file
C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf
to add virtual host entries.
Add following lines to the file.
<VirtualHost 127.0.0.1>
DocumentRoot "C:/websites/myproject/public/"
ServerName project.localhost.com
ServerAlias project.localhost.com
</VirtualHost>
You may also need to remove any example virtual hosts.
After this restart your apache and test the url http://project.localhost.com/ in browser.
于 2012-06-17T03:35:06.850 に答える