虚拟主机(Virtual Host)是指在一个机器上运行多个网络站点 (比如:www.company1.com和www.company2.com)。 如果每个网络站点拥有不同的IP地址,则虚拟主机可以是"基于IP"的; 如果只有一个IP地址,也可以是"基于主机名"的, 其实现对最终用户是透明的。具体细节可以查看Apache官方说明 。

一. “基于主机名”虚拟主机的配置

Listen 81 
  NameVirtualHost *:81 
  <VirtualHost *:81 >
       ServerAdmin example@company.com
       DocumentRoot  yourRoot 
      <Directory "yourRoot ">
       Options FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all 
      </Directory>
  </VirtualHost>
 配置说明:

81 : 为端口号,可以是其他现在系统未用的端口

yourRoot : linux下格式形如: /export/www    注意最后没有"/"

将上面的添加到apache的配置文件httpd.conf(linux下在/usr/local/apache2/conf/,视具体情况而定),然后重新启动Apache .

注意:

要配置基于主机名的虚拟主机,必须保留原有的80端口。

二. 查看配置是否成功

在浏览器中输入 http://localhost:81 查看是否配置成功。

 三. 常见问题常见解决方案

当在浏览器中查看配置成功与否出现问题时,可优先到Apache官方网站的FAQ 上或用搜索引擎搜索你的问题。

我这里就最常见403问题:

Forbidden

You don't have permission to access / on this server.

提供几种常见的解决方法:

1.按上面的配置正确,特别是:

Order allow,deny
       Allow from all

2. 确保youRoot文件夹下有index.html文件(或名为index而后缀为其他形式(如.jsp .php等)的文件) ,因为Apache默认以index.html为网站首页,如果没有这个文件就会出现上面的403错误。

注:如果你想以其他形式的文件(如:index.jsp或index.php等)作为出现的网页,可将Apache的配置文件中的:

<IfModule dir_module>
       DirectoryIndex index.html
   </IfModule>
   改为(如你想用index.jsp):

<IfModule dir_module>
       DirectoryIndex index.html index.jsp 
   </IfModule>

如果需要浏览该文件夹下的内容,可以在</Directory>前添加:

Options Indexes

就可以了。
  3. 针对linux用户,windows或其他用户一般没这种情况。linux系统中一般会自带apache,在修改了配置文件后,最好到安装Apache的目录下重启Apache。

问题解决:Apache: You don't have permission to access / on this server的更多相关文章

  1. (转) 问题解决:Apache: You don't have permission to access / on this server

    问题解决:Apache: You don't have permission to access / on this server 转自:http://blog.csdn.net/crazyboy20 ...

  2. Apache: You don't have permission to access / on this server

    当我们需要使用Apache配置虚拟主机时,有可能会出现这个问题:Apache: You don't have permission to access / on this server # 同IP不同 ...

  3. Mac apache You don't have permission to access / on this server.

    在mac下配置完apache和php环境后,通过localhost访问页面,出现403Forbidden.页面提示: Forbidden You don't have permission to ac ...

  4. apache You don't have permission to access / on this server.无权访问

    环境:ubuntu16.4 apache2 原因:修改了apache web项目路径 解决: 1. 修改 /etc/apache2/sites-available/000-default.conf 文 ...

  5. Apache提示You don't have permission to access / on this server问题解决

    测试时遇到将一本地目录设置为一apache的虚拟主机,在httpd-vhosts.conf文件中进行简单设置,然后在hosts文件中将访问地址指向本地,启动apache,进行访问,却出现了You do ...

  6. apache出现You don’t have permission to access / on this server问题的解决

    今天在部署一个系统时,在apache中新开了一个VirtualHost,然后设置了DocumentRoot,等访问时却提示“You don’t have permission to access / ...

  7. php多站点配置以及Forbidden You don't have permission to access / on this server问题解决

    php多站点配置以及Forbidden You don't have permission to access / on this server问题解决 一.总结 一句话总结:我的问题是php的版本问 ...

  8. apache出现You don't have permission to access / on this server. 提示

    今天在新的linux上跑原来的代码,使用的虚拟主机的模式进行操作.几个相关的网站放在一个文件里,想法是通过网站列出的目录进行相应的网站进行操作.一切设置完成后,在浏览器中运行出现在You don't ...

  9. WampServer phpadmin apache You don't have permission to access

    1.Forbidden You don't have permission to access / on this server. 后来咨询了一下朋友(php高手),说修改一下php的配置文件http ...

随机推荐

  1. windows中80端口被System占用,PID=4的问题

    在windows中如果tomcat需要使用80端口,发现该端口已经被占用,而netstat -ano发现该80端口被一个System的进程占用了,而PID=4.我们可以通过下面的方式找到对应的进程,然 ...

  2. Java并发编程:什么是线程安全,以及并发必须知道的几个概念

    废话 众所周知,在Java的知识体系中,并发编程是非常重要的一环,也是面试的必问题,一个好的Java程序员是必须对并发编程这块有所了解的.为了追求成为一个好的Java程序员,我决定从今天开始死磕Jav ...

  3. Java学习第二篇 — 时间类的使用

    package DateTest; import java.util.Date; public class Date1 { public static void main(String[] args) ...

  4. Bell(矩阵快速幂+中国剩余定理)

    Bell Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status  ...

  5. 安装mysql出现no compatible servers were found

    一.问题描述 今天在安装数据库的过程中,遇到错误提示: No compatible servers were found,You'll need to cancel this wizard and i ...

  6. 手动创建script解决跨域问题(jsonp从入门到放弃)

    vue项目一般用axios代替jQuery发送ajax请求,但是不支持jsonp格式,需要安装jsonp的依赖包,这就很不爽了,能自己轻易实现的,为什么要引乱七八糟的插件.jsonp其实就是利用< ...

  7. 去除img默认的边框

    //当img属性src没有值时,会有难看的边框和难看的一个小图 有什么办法去掉呢? <img  src=" " /> //不要这样写 <img   />  ...

  8. Wireshark wireshake数据包分割及捕包过滤器介绍

    wireshake数据包分割及捕包过滤器介绍 by:授客 QQ:1033553122 wireshake自带工具editcap分割数据包 操作: 进入到目录,然后 editcap.exe -c < ...

  9. Android友盟增量更新

    1.增量升级的原理 增量更新的原理就是将本地apk与服务器端最新版本比对,并得到差异包.比如现在的版本是1.1.4,大小是7.2M,新版本是1.1.5.大小是7.3M.我们发现两个版本只有0.1M的差 ...

  10. python + Jenkins + requests 数据驱动接口测试 环境部署

    ** Jenkins安装: * 安装包选择:Jenkins.war * windows下有msi和war两种格式,我使用的是war,下载下来丢到xmapp的指定目录就行,操作方便一点      * m ...