WAMP服务器虚拟主机配置 [英] WAMP Server virtual hosts configuration

查看:218
本文介绍了WAMP服务器虚拟主机配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK,我已经安装了WAMP根本无法设置我的虚拟主机正常。

下面是我有:

WAMP的安装目录: F:\\ WAMP

项目目录: F:\\ WWW

 #F:\\ WAMP \\ BIN \\ apache的\\ apache2.4.2 \\的conf \\额外\\的httpd-vhosts.conf
<目录F:\\ www的>
    设置AllowOverride AuthConfig FileInfo的指标限制选项
    为了拒绝,允许
    所有的AllowOverride
    所有允许
< /目录>127.0.0.1了NameVirtualHost
<虚拟主机127.0.0.1>
    服务器名本地主机
    的DocumentRootF:\\ WAMP \\ www的
< /虚拟主机>#是的,这是一个Symfony2的项目
<虚拟主机127.0.0.1>
    的DocumentRootF:\\ WWW \\ MY_PROJECT \\ WEB
    DirectoryIndex的app_dev.php
    服务器名MY_PROJECT
< /虚拟主机>

主机从Windows文件的配置和有必要的: 127.0.0.1 PROJECT_NAME 行包括

阿帕奇的httpd.conf

 #虚拟主机
包括的conf /额外/的httpd-vhosts.conf

现在的浏览器告诉我这,访问URL时: MY_PROJECT /

 故宫
您没有权限访问/在此服务器上。

可能有人给我什么是怎么回事线索?


解决方案

试试这个作为你的conf /额外/的httpd-vhosts.conf

 
#使用基于名字的虚拟主机。

*了NameVirtualHost:80
##必须先使WAMP的菜单页面加载
##,离开从127.0.0.1作为作为允许外部访问不应该被要求在网页WAMP
<虚拟主机*:80>
    的ServerAdmin webmaster@homemail.net
    的DocumentRootF:/ WAMP / WWW
    服务器名本地主机
    ServerAlias​​本地主机
    <目录F:/ WAMP / WWW>
        为了拒绝,允许
        所有拒绝
        从127.0.0.1允许
    < /目录>
< /虚拟主机>#是的,这是一个Symfony2的项目
<虚拟主机*:80>
    的DocumentRootF:\\ WWW \\ MY_PROJECT \\ WEB
    服务器名myproject.dev
    ServerAlias​​ myproject.dev www.myproject.dev
    选择了FollowSymLinks索引
    <目录F:\\ WWW \\ MY_PROJECT \\ WEB>
        所有的AllowOverride
        为了拒绝,允许
        从127.0.0.1允许
        来自192.168.2允许
        ##更改所有为允许时,它的工作原理
    < /目录>
< /虚拟主机>

现在,您需要将网站名称(S)添加到您的主机文件是这样的。

  127.0.0.1 myproject.dev
:: 1 myproject.dev

编辑:

有关浏览器中找到您的网站的域名,你必须告诉您正在使用用于测试的域名存在该IP地址的窗口和它生活的。您可以通过添加你的测试域名到一个名为 hosts文件做到这一点。这是由一种叫做服务时,窗口加载它的网络组件读取和缓存 DNS客户端

要加你必须编辑Windows主机文件中的新本地域名

  C:\\ WINDOWS \\ SYSTEM32 \\ DRIVERS \\ ETC \\主机

和添加一行为每个虚拟主机像这样

  127.0.0.1 myproject.dev
127.0.0.1 myproject2.dev
127.0.0.1 myproject3.dev
:: 1 myproject.dev
:: 1 myproject2.dev
:: 1 myproject3.dev

一旦被保存,使用以管理员身份运行(右击+在Windows命令处理器插画移位启动命令提示符,以显示包含<$ C $菜单C>以管理员身份运行菜单线),并发出以下两个命令所以它拿起您的更改重新启动DNS客户端服务。或者只是重新启动。

 净停止的dnscache

这是完成时

 网​​络启动的dnscache

PS。双引号是必需的,因为在服务名称空间!

如何修改hosts文件

hosts文件被Windows保护,为了拯救它,你必须具有管理员的privilages。
在Vista / W7 / W8你可能会认为你是一个管理员,但你不是。

要成功地保存hosts文件,这样做是为了推出具有管理员的privilages你的编辑器。

在桌面上找到或从开始菜单中的图标编辑器(记事本,如果你没有什么别的都行)
右键单击+ SHIFT在您选择的编辑器图标 - 将显示一个菜单。
从菜单中选择以管理员身份运行。

使用文件 - &GT;打开浏览你的编辑到 C:\\ WINDOWS \\ SYSTEM32 \\ DRIVERS \\ ETC \\主机文件

当你做出了修改,你现在将被允许保存它们。

OK, I have my wamp installed and simply can't setup my virtual hosts properly.

Here's what I have:

Wamp install dir: F:\wamp

Projects dir: F:\www

# F:\wamp\bin\apache\apache2.4.2\conf\extra\httpd-vhosts.conf
<Directory "F:\www">
    AllowOverride AuthConfig FileInfo Indexes Limit Options
    Order Deny,Allow
    AllowOverride All
    Allow from all
</Directory>

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
    ServerName localhost
    DocumentRoot "F:\wamp\www"
</VirtualHost>

# Yes, it's a symfony2 project
<VirtualHost 127.0.0.1>
    DocumentRoot "F:\www\my_project\web"
    DirectoryIndex app_dev.php
    ServerName my_project
</VirtualHost>

hosts file from windows is configured and has the necessary: 127.0.0.1 project_name line included.

Apache httpd.conf:

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

Now the browser tells me this, when accessing URL: my_project/

Forbidden
You don't have permission to access / on this server.

Could somebody give me a clue on what's going on here?

解决方案

Try this as your conf/extra/httpd-vhosts.conf

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80


## must be first so the the wamp menu page loads
## and leave as Allow from 127.0.0.1 as outside access should not be required to the wamp homepage
<VirtualHost *:80>
    ServerAdmin webmaster@homemail.net
    DocumentRoot "F:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "F:/wamp/www">
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

# Yes, it's a symfony2 project
<VirtualHost *:80>
    DocumentRoot "F:\www\my_project\web"
    ServerName myproject.dev
    ServerAlias myproject.dev www.myproject.dev
    Options Indexes FollowSymLinks
    <Directory "F:\www\my_project\web">
        AllowOverride All
        Order Deny,Allow
        Allow from 127.0.0.1
        Allow from 192.168.2
        ## change to Allow from all when it works
    </Directory>
</VirtualHost>

Now you need to add the site name(s) to your hosts file like this.

127.0.0.1 myproject.dev 
::1 myproject.dev 

EDIT:

For your browser to find your site domain names you must tell windows that the domain name you are using for testing exists and which ip address it lives on. You do this by adding your testing domain names to a file called hosts. This is read when windows loaded its networking component and cached by a service called DNS Client

To add new local domain names you must edit the windows hosts file

c:\windows\system32\drivers\etc\hosts

And add one line for each of your virtual hosts like this

127.0.0.1  myproject.dev
127.0.0.1  myproject2.dev
127.0.0.1  myproject3.dev
::1  myproject.dev
::1  myproject2.dev
::1  myproject3.dev

Once this is saved, launch a command prompt using Run as Administrator (right click + shift over the Windows command processor icon to show a menu containing the Run as Administrator menu line) and issue these 2 commands to restart the 'DNS Client' service so it picks up your changes. Alternatively just reboot.

net stop dnscache

when that completes

net start dnscache

PS. The double quotes are required as there is a space in the service name!

HOW TO EDIT THE HOSTS FILE

The hosts file is protected by windows, in order to save it you must have Administrator privilages. On Vista/W7/W8 you may think you are an Administrator BUT YOU ARE NOT.

To successfully save the hosts file do this to launch your editor with Admin Privilages.

Locate your editors icon on the desktop or from the Start menus ( notepad will do if you have nothing else ) right click + shift over your chosen editor icon - will show a menu. select "Run As Administrator" from the menu.

Using file -> open Navigate your editor to the c:\windows\system32\drivers\etc\hosts file.

When you have made changes you will now be allowed to save them.

这篇关于WAMP服务器虚拟主机配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆