WAMP集成环境虚拟机配置问题

1:安装完成后,先编辑D:\wamp\bin\apache\apache2.2.22\conf下的http.conf文件,去掉#Include 0conf/extra/httpd-vhosts.conf前面的#号!!

2:找到安装目录D:\wamp\bin\apache\apache2.2.22\conf\extra\httpd-vhosts.conf找到VirtualHost节点 加入下一段即可
  <VirtualHost *:80>
    ServerName www.test.com  
    ServerAlias www.test.com     
    DocumentRoot E:/test  
 <Directory "E:/test">       
   Options Indexes FollowSymLinks 
    AllowOverride all 
    Order Allow,Deny 
    Allow from all                        
 </Directory>
</VirtualHost>

php5.5及以上版本

<VirtualHost *:80>
    DocumentRoot "D:\www\laravel5.1\public"
    ServerName selfstudy.com
    <Directory "D:\www\laravel5.1">
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>
</VirtualHost>


3: 修改Hosts文件 C:\WINDOWS\system32\drivers\etc\Hosts
127.0.0.1   www.test.com


有些时候配置完了虚拟主机发现访问localhost不会出现wamp的默认界面或者出现 / 根目录找不到的情况,因为没有配置localhost,加入如下配置即可

<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "F:\wamp\www"
<Directory "F:\wamp\www">
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>


# localhost访问默认根目录(php5.5及以上版本)
<VirtualHost *:80>
    DocumentRoot "D:\wamp\www"
    ServerName localhost
    <Directory "D:\wamp\www">
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>
</VirtualHost>

4:重启apache

5:如果出现403错误或者权限问题,把httpd.conf文件中的deny from all修改为 allow from all(php5.5及以上版本把<Directory />
    AllowOverride none
    Require all denied
</Directory>改成Require all granted

6:如何在本地配置让别人可以直接访问你本地的项目

① 通过局域网ip访问

<VirtualHost 192.168.0.144:80>
ServerName test.chinanet.com
DocumentRoot "E:\www\chinanet"
<Directory "E:\www">
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>


②通过域名(本地虚拟域名)访问

<VirtualHost *:80>
ServerName army.com
DocumentRoot "E:\army"
<Directory "E:\army">
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

本地hosts配置  127.0.0.1        army.com
同一局域网内要访问你的机器的hosts配置  192.168.1.68(我机器的ip)       army.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值