本文主要是介绍Windows 下 Apache Virtualhost 设置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Apache with virtual host on Windows
一个很平常的问题,windows下怎么在apache上设置 virtualhost (虚拟主机),其实很简单。
这儿以xampp 为例。
第一,设置域名解析。
我们需要打开 host 这样一个文件,不同单位 windows 版本,其位置也不近相同,
Windows 3.1/95/98/ME:
c:\windows\hosts
Windows NT/2000/XP Pro:
c:\winnt\system32\drivers\etc\hosts or c:\windows\system32\drivers\etc\hosts
Windows XP Home:
c:\windows\system32\drivers\etc\hosts
Windows Vista:
C:\Windows\System32\Drivers\etc\hosts
用记事本打开 host 文件,如果你是vista,需要以administrator 运行记事本,在最下面添加:
127.0.0.1 wordpress.do
127.0.0.1 websitebaker.do
左边的ip 是这台电脑的IP地址,右边的是虚拟主机名(设置成功后就可以以这个虚拟主机名访问目录)。
来源:(http://blog.sina.com.cn/s/blog_60b5a8750100djpl.html) - Windows 下 Apache Virtualhost 设置_风中这尘_新浪博客
第二,编辑httpd-vhosts.conf
用记事本打开httpd-vhosts.conf,该文件在xampp\Apache2.2\conf\extra,把下面的代码复制进去。
<VirtualHost *:80> DocumentRoot /xampplite/htdocs ServerName localhost <Directory /> Options FollowSymLinks AllowOverride All </Directory> </VirtualHost><VirtualHost *:80> ServerName websitebaker.do #虚拟主机(virtualhost) DocumentRoot D:/xampp/htdocs/websitebaker #网站物理地址 <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory D:/xampp/htdocs/websitebaker> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost><VirtualHost *:80> ServerName wordpress.do DocumentRoot D:/xampp/htdocs/wordpress <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory D:/xampp/htdocs/wordpress> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
然后把 #NameVirtualHost *:80 前面的“#”去掉。保存文件退出。
第三,重新启动 apache service。
第四,OK,现在你可以用 http://wordpress.do 代替原来的http://localhost/wordpress
访问网站了.
文章出处http://www.yaoyingying.com/
来源:(http://blog.sina.com.cn/s/blog_60b5a8750100djpl.html) - Windows 下 Apache Virtualhost 设置_风中这尘_新浪博客
这篇关于Windows 下 Apache Virtualhost 设置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!