服务器apache下绑定域名到指定目录的方法

来源:互联网 发布:诺基亚c6 01视频软件 编辑:程序博客网 时间:2024/05/21 06:38

第一步 DNS

操作系统中这个文件位于WINNT\system32\drivers\etc 目录下,文件名为hosts。 

打开就能看到 

127.0.0.1 localhost 

添加

127.0.0.1 my.test.com

 

第二步 apache

方法一:

在httpd.conf最后加上,如下.... 
<VirtualHost *:80>

NameVirtualHost *

ServerName test.com   #要绑定的域名

DocumentRoot D:/www/myz    #虚拟主机目录(网站根目录) 
</VirtualHost> 

重启apache 

 

方法二:

在conf/extra/httpd-vhosts.conf文件里搜索vhost,然后把前面的#去掉

然后在conf/httpd.conf文件的最下面加入:

<VirtualHost *:80>
    ServerAdmin webmaster@test.com //邮箱名
    DocumentRoot "D:\xampp\htdocs\test"//指定文件地址
    ServerName my.test.com #绑定的域名
 <Directory "D:\xampp\htdocs\test">
  Options Indexes FollowSymLinks Includes ExecCGI
  AllowOverride All
  order allow,deny
  Allow from all
 </Directory>
</VirtualHost>

 

原创粉丝点击