wamp虚拟服务器

1、安装好wampServer

2、修改配置文件包含 vhosts 文件,操作: 打开apache的配置文件httpd.conf,并去掉#Include conf/extra/httpd-vhosts.conf前面的#,作用启用虚拟主机功能

2、先把localhost配置好,免得以后访问localhost出现问题,我的wamp项目根目录是E:wampwww。

将下面信息添加到apache的apache/conf/extra下的配置文件httpd-vhosts.conf后面即可;  (若修改apache.conf中<Directory "E:/gslab">   DocumentRoot "E:/gslab" 可默认访问路径)

<VirtualHost *:80>
DocumentRoot "E:/wamp/www"
ServerName localhost
DirectoryIndex index.php
<Directory E:/wamp/www/>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

然后另定义一个域名,

“DirectoryIndex index.php”的意思是访问该目录默认打开“index.php”文件

<VirtualHost *:80>
DocumentRoot "E:/wamp/www/demo"
ServerName test.oa.com
DirectoryIndex index.php
<Directory E:/wamp/www/>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

3、修改C:WindowsSystem32driversetc下的host文件,用记事本打开,添加 127.0.0.1    test.oa.com  ,重启apache即可。

4、效果

 扩展一

打开配置文件httpd.conf,找到监听端口位置 Listen 80,并在其下增加内容

Listen 80
Listen 8180
Listen 8181

查看 端口占用情况,可以 知晓 apache 服务情况

5、作用 a)方便管理本地项目 b)配合跨域请求,进行前后台代码的分离(方式chrome跨域请求)

原文地址:https://www.cnblogs.com/blog-index/p/6556387.html