最近用到了wamp环境,想创建一个虚拟主机,可是忘记了,于是百度了一下,把它写下来:

环境wampserver 2.4

找到安装目录,进入apache安装目录:找到conf 下的 httpd.conf

默认是 C:\wamp\bin\apache\Apache2.2.21\conf  下的httpd.conf

找到这么一句

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

改为

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

意思是开始虚拟主机配置,在conf/extra/httpd-vhosts.conf 下配置

模式的配置地址 C:\wamp\bin\apache\Apache2.2.21\conf\extra    httpd-vhosts.conf

找到和下面一样的代码,原本是不带#号的:

#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot "c:/Apache2/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:/Apache2/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>

    DocumentRoot "D:/www"
ServerName baidu.com
<Directory "D:/www">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all </Directory>
</VirtualHost>

详细说明:

<VirtualHost *:80>

    DocumentRoot "虚拟主机目录,项目路径"
ServerName 虚拟主机名字,也就是在本地访问的网址
<Directory "D:/www"> 对所给予的目录设置权限
Options Indexes FollowSymLinks
AllowOverride None  // 在 AllowOverride 设置为 None 时, .htaccess 文件将被完全忽略
Order allow,deny
Allow from all </Directory>
</VirtualHost>

在你的目录下面放一个php文件,检测是否成功,我们普遍在里面写一句phpinfo,

以上是我用wamp配置的过程,最后可以成功访问php文件

新版apache 语法

<VirtualHost *:80>
ServerAdmin lenwang@tencent.com
ServerName sg.automall.qq.com
ServerAlias sg.automall.qq.com
DocumentRoot D:/svn/sg/trunk <LocationMatch "/data/.*\.php$">
Order Deny,Allow
Deny from All
</LocationMatch> <Directory />
# Options -Indexes FollowSymLinks
Require all granted
AllowOverride All
</Directory> # ErrorLog logs/newprj.qq.com-error_log SetEnv MOD_ENV DEVELOPMENT RewriteEngine on
RewriteCond %{REQUEST_URI} !^.*(.css|.js|.gif|.png|.jpg|.jpeg|.ico|.woff|.svg|.eot)$
RewriteRule .* /index.php
</VirtualHost>

wampserver 2.4 配置虚拟主机的更多相关文章

  1. wampserver下配置虚拟主机 实现多站点支持

    wampserver下配置虚拟主机 实现多站点支持 wampserver是由德国人开发,在windows环境下实现apache+php+mysql的一款集成环境软件,wampserver自带SQLit ...

  2. 使用WampServer环境,如何配置虚拟主机域名

    很多人不会配置虚拟主机,我这里简单交一下大家,分三步: 1.在 C:\Windows\System32\drivers\etc 文件夹中的文件 Hosts 文件修改代码为: 127.0.0.1 loc ...

  3. PHP 使用WampServer环境,如何配置虚拟主机域名

    很多人不会配置虚拟主机,我这里简单交一下大家,分三步: 1.在 C:\Windows\System32\drivers\etc 文件夹中的文件 Hosts 文件修改代码为: 127.0.0.1 loc ...

  4. Wampserver2.5配置虚拟主机出现403 Forbidden的处理方案

    WampServer是一款由法国人开发的Apache Web服务器.PHP解释器以 及MySQL数据库的整合软件包.免去了开发人员将时间花费在繁琐的配置环境过程,从而腾出更多精力去做开发.在windo ...

  5. Wampserver2.5配置虚拟主机出现403 Forbidden解决办法

    一直在用APMServ5.2.6,mysql好办,可以用mariadb代替进行升级,但php升级到5.4.7就没办法再升级,安装加速器也困难.就想迁移到Wampserver上来,以前也尝试过Wamps ...

  6. Linux + Apache + MySql+ Php 配置虚拟主机

    win7:------------------------------------------------------------------------ NameVirtualHost *:80&l ...

  7. CentOS 7 配置虚拟主机站点

    1.进入/etc/httpd/conf 下 将httpd.conf 打开. 2.将DocumentRoot注释掉.(将ServerName 打开要不会有错误警告). 3.将虚拟主机站点配置包含进来:I ...

  8. 【转】Apache 配置虚拟主机三种方式

    Apache 配置虚拟主机三种方式  原文博客http://www.cnblogs.com/hi-bazinga/archive/2012/04/23/2466605.html 一.基于IP 1. 假 ...

  9. apache配置虚拟主机

    步骤如下: 1.在配置文件httpd.conf中启用httpd-vhosts.conf 找到# Virtual hosts将Include conf/extra/httpd-vhosts.conf前的 ...

随机推荐

  1. JPA2.1 中三个提升应用性能的新功能

    经常在网上看到开发者们抱怨 JPA 性能低下的帖子或文章,但如果仔细查看这些性能问题,常会发现导致问题的根本原因大致包括以下几个: 使用过多的 SQL 查询从数据库中获取所需的实体信息,即我们常说的n ...

  2. King's Quest

    poj1904:http://poj.org/problem?id=1904 题意:国王有n个儿子,现在这n个儿子要在n个女孩里选择自己喜欢的,有的儿子可能喜欢多个,最后国王的向导给出他一个匹配,匹配 ...

  3. 【转】python3 发邮件实例(包括:文本、html、图片、附件、SSL、群邮件)

    特别留意群邮件方式,这是工作中用得多的. 附件,HTML,图片,都需要的. 文件形式的邮件 [python] view plain copy 1.#!/usr/bin/env python3 2.#c ...

  4. Keil 程序调试窗口

    上一讲中我们学习了几种常用的程序调试方法,这一讲中将介绍Keil提供各种窗口如输出窗口.观察窗口.存储器窗口.反汇编窗口.串行窗口等的用途,以及这些窗口的使用方法,并通过实例介绍这些窗口在调试中的使用 ...

  5. RESTful风格的Web服务框架:Swagger

    Swagger与SpringMVC项目整合 为了方便的管理项目中API接口,在网上找了好多关于API接口管理的资料,感觉目前最流行的莫过于Swagger了,功能强大,UI界面漂亮,并且支持在线测试等等 ...

  6. sort merge join,hash join,netsloop join

    Join Operations ? SORT-MERGE JOIN – Sorts tables on the join key and then merges them together – Sor ...

  7. BZOJ2342: [Shoi2011]双倍回文

    2342: [Shoi2011]双倍回文 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 923  Solved: 317[Submit][Status ...

  8. redis3.0集群搭建

    生产环境中准备使用redis3.0集群了,花了一天时间研究了一下,下面记录一下集群搭建的过程. 服务器规划: 192.168.116.129    7000,7003 192.168.116.130 ...

  9. gcc编译器参数使用及解决

    gcc -c CStringAndPointer.c -o CStringAndPointer.o 执行时出现问题: ./CStringAndPointer.o bash: ./CStringAndP ...

  10. Mac 系统显示和隐藏文件的方法

    1. 代码法: 显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool true 隐藏Mac隐藏文件的命令:defau ...