安装Apache配置虚拟目录

首先在apache的安装目录下找到conf目录下找到httpd.conf文件

然后搜索hosts找到 把前面的井号去掉即可启动虚拟主机

 

 

 

2、然后在apache的安装目录下找到conf目录下的extra找到httpd-vhosts.conf文件

  1. #配置我们自己的虚拟主机  
  2. <VirtualHost *:80>  
  3.     #修改文档根路径  
  4.     DocumentRoot "D:/Program Files (x86)/myenv/apache2.2.25/htdocs"  
  5.     #主机名称  
  6.     ServerName myvirtualhost.com  
  7.     #欢迎页面  
  8.     DirectoryIndex index.html  
  9.     <Directory "D:/Program Files (x86)/myenv/apache2.2.25/htdocs">  
  10.     Options -Indexes FollowSymLinks  
  11.     AllowOverride None  
  12.     Order allow,deny  
  13.     Allow from all  
  14.     </Directory>  
  15.     #错误日志存放位置  
  16.     ErrorLog "logs/myvirtualhost.com-error.log"  
  17.     CustomLog "logs/myvirtualhost.com-access.log" common  
  18. </VirtualHost>  
  19. 在host文件中添加虚拟主机  高亮部分

     

  20. 二、apache虚拟目录的配置

     

     

    1、首先在apache的安装目录下找到conf目录下找到httpd.conf文件

     

    搜索DocumentRoot  找到下面的位置 自定义的时候可以把这个关闭 ,不关闭好像也没影响

     

    2、找到<IfModule>这块,加入下面的代码

    1. # 虚拟目录,访问D盘下面的web目录  
    2. <IfModule dir_module>  
    3.     # 设置缺省载入页面  
    4.     DirectoryIndex index.html index.htm index.php  
    5.     # 设置站点别名,别名与访问路径是相关的,取任何名称都可以(除特殊)  
    6.     Alias /myweb "D:/web"  
    7.     <Directory D:/web>  
    8.     # 设置访问权限  
    9.         Order allow,deny  
    10.     Allow from all  
    11.     </Directory>  
    12. </IfModule>  

    修改完成后重启Apache服务器 在浏览器中输入:http://localhost/myweb/xx.php 来访问 D:/web 下的文件

 

posted @ 2017-10-09 08:32  Nevr  阅读(423)  评论(0编辑  收藏  举报