虚拟主机(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。

http://blog.csdn.net/crazyboy2005/article/details/4768928

转载于:https://www.cnblogs.com/chen110xi/p/3719987.html

问题解决:Apache: You don't have permission to access / on this server相关推荐

  1. apache:You don't have permission to access on this server.

    You don't have permission to access on this server. 查日志: No matching DirectoryIndex (index.html) fou ...

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

    Apache提示You don't have permission to access / on this server问题解决 参考文章: (1)Apache提示You don't have per ...

  3. 【Apache】You don't have permission to access / on this server.问题解决

    目录 背景 正文 总结 背景 在服务器中输入localhost出现 Forbidden,You don't have permission to access / on this server. 在外 ...

  4. you don't have permission to access / on this server(Apache Server权限访问问题)

    Apache Http Server已经在linux上安装完成,可是通过浏览器访问,却出现了"you don't have permission to access / on this se ...

  5. 输入http://localhost/,apache出现You don't have permission to access/on this server.的提示,如何解决?...

    本地搭建wamp,输入http://127.0.0.1访问正常,当输入http://localhost/,apache出现You don't have permission to access/on ...

  6. [备忘][转载]apache 403错误 You don't have permission to access on this server

    apache 403错误 You don't have permission to access on this server. 在配置好了Apache服务器后,测试已经通过了,但是通过浏览器访问lo ...

  7. (已解决)wamp + Apache报错:出现403Forbidden You don't have permission to access / on this server.

    文章目录 `解决办法:` `*** `附件 · 延伸阅读 · 参考: 解决办法: 注意: 案例环境:win7 x64 或 win10 仅仅只需要修改apache配置文件httpd.conf 即可. 上 ...

  8. [乐意黎原创]访问Centos下Apache主机页面抛You don't have permission to access / on this server.

    Forbidden You don't have permission to access / on this server. Server unable to read htaccess file, ...

  9. Linux Centos7 Apache 访问 You don't have permission to access / on this server.

    折腾了很久,今天才找到了最正确的答案.感言真不容易. 百度出来的99%都是采集的内容,全都是错误的. You don't have permission to access / on this ser ...

最新文章

  1. 6月27日任务 配置Tomcat监听80端口、配置Tomcat虚拟主机、Tomcat日志
  2. java链式编程_Java 链式编程 和 lombok 实现链式编程
  3. 【知识库专访】亲加CTO郝飞:直播技术架构解密与优化之道
  4. web前端常用代码于面试等资源
  5. 【渝粤教育】广东开放大学 PHP动态网站设计 形成性考核 (48)
  6. 【MongoDB 工具篇】MongoDB Compass介绍与简单使用
  7. java 异步_聊聊java高并发系统之异步非阻塞
  8. 非递归分治法排序 MergeSort without recursion
  9. 中国互联网网站尴尬排行榜[转]
  10. 【BZOJ】2553: [BeiJing2011]禁忌 AC自动机+期望+矩阵快速幂
  11. 为什么现在的很多酒店都不收押金,只收房费了?
  12. plt.imshow显示CT/MRI图像
  13. think in uml 2.1
  14. Verilog初级教程(18)Verilog中的函数与任务
  15. 当HR压你价,说你只值7K,你该怎么回答?
  16. 美化windows xp 完全教程
  17. 卡耐基梅隆大学教授邢波:Petuum,大数据分布式机器学习平台
  18. brew install速度过慢
  19. 电子学会2022年9月青少年软件编程(图形化)等级考试试卷(三级)答案解析
  20. 2019 徐州 icpc 树状数组套线段树 H - Yuuki and a problem

热门文章

  1. mysql定时备份并上传ftp_Linux下定时任务实现mysql自动备份并上传远程ftp
  2. 5.3.5 TCP拥塞控制
  3. Xilinx ISE 开发过程中生成的各种文件(一)
  4. C++求n个字符的长度为m的组合
  5. 从源码分析DEARGUI之add_text_point
  6. 遗传和基因突变对神经网络训练的好处
  7. Javascript标准DOM Range操作
  8. python django开发问题
  9. 一种快速统计SQL Server每个表行数的方法
  10. 用gulp构建你的前端项目