Apache搭建多个站点方法详解
最平常的大概有3种方法。
第一种:单IP不同端口
第二种:多IP同端口(独立IP的虚拟空间)
第三种:域名绑定根目录的方式(共享IP的虚拟空间)
Apache的核心配置文件名是”httpd.conf”,其所存放的路径在Apache目录下的conf文件夹下。修改它只需要使用记事本(建议使用其他编辑器,带行数的那种,方便修改),生效的话只需要保存httpd.conf,重启apache即可。
下面多站点支持的话,修改httpd.conf的第187~264行(不同的httpd.conf可能有差异),也就是在ServerAdmin和ServerName那里,大部分是注释。下面是主要修改的地方。
注意:如果是服务器请备份httpd.conf后再修改文件。
代码如下 | 复制代码 |
# 'Main' server configuration # # # # # # # |
第一种一般是测试环境,毕竟加了端口,如何绑定域名,访问的时候域名后面也需加端口。
例子分别通过80和8080访问不同的根目录。
大概在50几行有个Listen 80,在下面添加8080端口。
代码如下 | 复制代码 |
Listen 80 |
第二种多IP同端口。
IP地址1:192.168.2.2
IP地址2:192.168.1.68
端口同是80端口。
代码如下 | 复制代码 |
<VirtualHost 192.168.1.68:80> |
第三种同IP不同域名和根目录(域名的话修改本地host演示)。
代码如下 | 复制代码 |
<VirtualHost 192.168.2.2:80> |
最新文章
- 自动生成Mapper和Entity工具MybatisGenerator的使用
- 东大OJ-1391-Big big Power
- An unknown server-side error occurred while processing the command.处理
- 转:Nginx配置指令location匹配符优先级和安全问题
- tabBar选中底部弹出窗口
- 1.1.2-学习Opencv与MFC混合编程之---画图工具 画直线 画圆 画矩形
- 单纯觉得是篇好文——跨终端Web之Hybrid App
- 用Token令牌维护微服务之间的通信安全的实现
- ●洛谷P1903 [国家集训队]数颜色
- 逐个使用C++11新特性
- python中的 list (列表)append()方法 与extend()方法的用法 和 区别
- UVA 10559 Blocks(区间DP&;&;递推)
- UIGestureRecognizer学习笔记
- java_对象序列化
- Class中isAssignableFrom() 方法
- BZOJ2407/4398:探险/福慧双修(最短路)
- shell 批量压缩指定目录及子目录内图片的方法
- Python3 Tkinter-Canvas
- [原创]Docker学习记录: Shipyard+Swarm+Consul+Service Discover 搭建教程
- UI(UGUI)框架(一)---------概述与保存/读取面板类型与路径
热门文章
- java.lang.ExceptionInInitializerError
- POJ 3691 AC自动机上的dp
- 在oracle中创建空间索引
- swing LayoutManager 和多态
- [Windows驱动]流媒体驱动开发
- Android获取手机设备识别码(IMEI)和手机号码
- Non-Programmer&#39;s Tutorial for Python 3/File IO
- Swift语言中如何使用JSON数据教程
- JDK的下载与安装
- (转)Android学习笔记---SQLite介绍,以及使用Sqlite,进行数据库的创建,完成数据添删改查的理解