分享三种Apache配置虚拟主机的方式
一、基于IP
1. 假设服务器有个IP地址为192.168.1.10,使用ifconfig在同一个网络接口eth0上绑定3个IP:
[root@localhost root]# ifconfig eth0:1 192.168.1.11
[root@localhost root]# ifconfig eth0:2 192.168.1.12
[root@localhost root]# ifconfig eth0:3 192.168.1.13
2. 修改hosts文件,添加三个域名与之一一对应:
192.168.1.11 www.test1.com
192.168.1.12 www.test2.com
192.168.1.13 www.test3.com
3. 建立虚拟主机存放网页的根目录,如在/www目录下建立test1、test2、test3文件夹,其中分别存放1.html、2.html、3.html
/www/test1/1.html
/www/test2/2.html
/www/test3/3.html
4. 在httpd.conf中将附加配置文件httpd-vhosts.conf包含进来,接着在httpd-vhosts.conf中写入如下配置:
ServerName www.test1.com DocumentRoot /www/test1/ Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow From All ServerName www.test1.com DocumentRoot /www/test2/ Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow From All ServerName www.test1.com DocumentRoot /www/test3/ Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow From All
栏 目:Linux
下一篇:Centos7 Mysql 5.6 多主一从 解决方案与详细配置
本文标题:分享三种Apache配置虚拟主机的方式
本文地址:https://www.idc91.com/fuwuqizl/2521.html
您可能感兴趣的文章
- 06-17Linux进程信号的发送和保存方法
- 06-17Linux卸载自带jdk并安装新jdk版本的图文教程
- 06-17Linux系统中卸载与安装JDK的详细教程
- 06-17Linux系统配置NAT网络模式的详细步骤(附图文)
- 06-17Linux中的计划任务(crontab)使用方式
- 06-17Apache配置域名跳转的详细步骤
- 06-17Linux fsync系统调用方式
- 06-17Linux磁盘扩容lvm的使用详解
- 06-17Linux与Windows跨平台文件共享的实现方案
- 06-17Linux如何实现给/根目录扩容


阅读排行
推荐教程
- 05-27Linux命令学习总结之rmdir命令
- 05-27阿里云linux服务器安全设置(防火墙策略等)
- 05-10Ubuntu系统安装ANSYS2021R1
- 05-27SecureCRT中文显示乱码问题的解决方法
- 06-12linux系统SSL证书部署https单/多站点
- 05-10ANSYS2021R1安装方法Linux centos Ubuntu系统
- 05-27apache密码生成工具htpasswd使用详解
- 11-07Clash Linux服务器安装详细教程
- 05-27Apache下开启SSI配置使html支持include包含的方法
- 05-27Linux下大量SYN_SENT连接问题的解决方法