本地apache虚拟主机的配置
第一步:在 C:\WINDOWS\system32\drivers\etc 下找到 hosts 文件 ,打开并且在最后加上
ServerAdmin 你的邮件地址(不过可以随便写,这也只不过是虚拟环境而已)
DocumentRoot 这是你项目的路径
ServerName 这是你的虚拟域名
有时候你把上面的127.0.0.1 换为 * 也可以。但是有时候不行。我建议还是加上。
我习惯于使用 wamp 所以我并没有加在配置文件的最后面,而是加在了以下两行代码之前:
127.0.0.1 localhost 127.0.0.1 uc.521-wf.com 127.0.0.1 uch.521-wf.com第二步:在apache 的配置文件 httpd.conf 的最后加上如下的代码:
但是这是核心的代码,不是固定的写法:
- NameVirtualHost 127.0.0.1
- <VirtualHost 127.0.0.1:80>
- ServerAdmin admin@521-wf.com
- DocumentRoot c:/wamp/www/
- ServerName localhost
- </VirtualHost>
- <VirtualHost 127.0.0.1:80>
- ServerAdmin admin@521-wf.com
- DocumentRoot c:/wamp/www/uc/
- ServerName uc.521-wf.com
- </VirtualHost>
- <VirtualHost 127.0.0.1:80>
- ServerAdmin admin@521-wf.com
- DocumentRoot c:/wamp/www/uch/
- ServerName uch.521-wf.com
- </VirtualHost>
ServerAdmin 你的邮件地址(不过可以随便写,这也只不过是虚拟环境而已)
DocumentRoot 这是你项目的路径
ServerName 这是你的虚拟域名
有时候你把上面的127.0.0.1 换为 * 也可以。但是有时候不行。我建议还是加上。
我习惯于使用 wamp 所以我并没有加在配置文件的最后面,而是加在了以下两行代码之前:
Include "c:/wamp/apache2/conf/alias/phpmyadmin.conf" Include "c:/wamp/apache2/conf/alias/sqlitemanager.conf"当然如果你的操作系统装在了d盘,或者是其他盘,那就看着办吧! 这个配置我在学校里面配置我好多次,不能说倒背如流,但是可以说是滚光烂熟了吧。但是到了公司,两个多月不用了,突然想装一下uchome ,配置了半天,老是出错 。所以 还是写在这儿,以防以后再忘了。 <<<<<<<<<<<<<<<<<<<<<<<<<<补充,还可以使用以下这种方式,更安全
- <VirtualHost *:80>
- DocumentRoot "D:/wamp/www/framework/webroot"
- ServerName star
- #ServerAlias *.shop.com.cn
- ErrorLog "logs/starland.ifensi-error.log"
- CustomLog "logs/make.openqee.com.cn.log" common
- <Directory "D:/wamp/www/framework">
- Options FollowSymLinks
- AllowOverride All
- Order deny,allow
- allow from all
- DirectoryIndex index.html index.php
- </Directory>
- </VirtualHost>