基于域名的服务端:
13 iptables -F
14 setenforce 0
15 ifconfig eth0 172.18.43.146
16 yum -y install bind bind-chroot
17 cd /var/named/chroot/
18 vim /etc/named.conf
19 vim /var/named/baidu.com.zone
编辑:$TTL 86400
@ IN SOA www.baidu.com. root (
2014081701
1H
1M
2W
1D
)

@ IN NS www.baidu.com.
www1.baidu.com. IN A 172.18.43.100
www2.baidu.com. IN A 172.18.43.102
20 /etc/init.d/named restart
21 vim /etc/httpd/conf/httpd.conf
22 mkdir /domain1
23 mkdir /domain2
24 echo domain1:www1.baidu.com >/domain1/index.html
25 echo domain2:www2.baidu.com >/domain2/index.html
26 /etc/init.d/named restart
27 /etc/init.d/httpd start
28 /etc/init.d/httpd restart
客户端访问验证:
iptables -F
setenforce 0
ifconfig eth0 172.18.43.147
vim /etc/resolv.conf
www1.baidu.com
www2.baidu.com

基于ip的服务端:
29 vim /etc/httpd/conf/httpd.conf
30 service httpd restart
31 mkdir /ip1
32 mkdir /ip2
33 echo ip1:172.18.43.148 >/ip1/index.html
34 echo ip2:172.18.43.149 >/ip2/index.html
35 ifconfig eth0:0 172.18.43.148
36 ifconfig eth0:0 172.18.43.149
37 service httpd restart
客户端访问验证:
http://172.18.43.148
http://172.18.43.149

基于端口服务端:
38 vim /etc/httpd/conf/httpd.conf
39 cd /ip1
40 cat index.html
41 ifconfig
42 ifconfig eth0:1 172.18.43.148
49 vim /etc/httpd/conf/httpd.conf
50 service httpd restart
51 mkdir /port1
52 mkdir /port2
53 echo port1:8080 > /port1/index.html
54 echo port2:8081 > /port2/index.html
55 service httpd restart
客户端访问验证:
172.18.43.146:8080
172.18.43.146:8081

apache里面的配置:
1.基于域名的:
NameVirtualHost *:80
<VirtualHost 172.18.43.100:80>
DocumentRoot /domain1
ServerName www1.baidu.com
</VirtualHost>
<VirtualHost 172.18.43.102:80>
DocumentRoot /domain2
ServerName www2.baidu.com
</VirtualHost>
2.基于ip的:
</VirtualHost>
<VirtualHost 172.18.43.148:80>
DocumentRoot /ip1
</VirtualHost>
<VirtualHost 172.18.43.149:80>
DocumentRoot /ip2
</VirtualHost>
3.基于端口的:
</VirtualHost>
Listen 8080
Listen 8081
<VirtualHost *:8080>
DocumentRoot /port1
ServerName 172.18.43.146:8080
</VirtualHost>
<VirtualHost *:8081>
DocumentRoot /port2
ServerName 172.18.43.146:8081
</VirtualHost>

基于域名的服务端:
13 iptables -F
14 setenforce 0
15 ifconfig eth0 172.18.43.146
16 yum -y install bind bind-chroot
17 cd /var/named/chroot/
18 vim /etc/named.conf
19 vim /var/named/baidu.com.zone
编辑:$TTL 86400
@ IN SOA www.baidu.com. root (
2014081701
1H
1M
2W
1D
)

@ IN NS www.baidu.com.
www1.baidu.com. IN A 172.18.43.100
www2.baidu.com. IN A 172.18.43.102
20 /etc/init.d/named restart
21 vim /etc/httpd/conf/httpd.conf
22 mkdir /domain1
23 mkdir /domain2
24 echo domain1:www1.baidu.com >/domain1/index.html
25 echo domain2:www2.baidu.com >/domain2/index.html
26 /etc/init.d/named restart
27 /etc/init.d/httpd start
28 /etc/init.d/httpd restart
客户端访问验证:
iptables -F
setenforce 0
ifconfig eth0 172.18.43.147
vim /etc/resolv.conf
www1.baidu.com
www2.baidu.com

基于ip的服务端:
29 vim /etc/httpd/conf/httpd.conf
30 service httpd restart
31 mkdir /ip1
32 mkdir /ip2
33 echo ip1:172.18.43.148 >/ip1/index.html
34 echo ip2:172.18.43.149 >/ip2/index.html
35 ifconfig eth0:0 172.18.43.148
36 ifconfig eth0:0 172.18.43.149
37 service httpd restart
客户端访问验证:
http://172.18.43.148
http://172.18.43.149

基于端口服务端:
38 vim /etc/httpd/conf/httpd.conf
39 cd /ip1
40 cat index.html
41 ifconfig
42 ifconfig eth0:1 172.18.43.148
49 vim /etc/httpd/conf/httpd.conf
50 service httpd restart
51 mkdir /port1
52 mkdir /port2
53 echo port1:8080 > /port1/index.html
54 echo port2:8081 > /port2/index.html
55 service httpd restart
客户端访问验证:
172.18.43.146:8080
172.18.43.146:8081

apache里面的配置:
1.基于域名的:
NameVirtualHost *:80
<VirtualHost 172.18.43.100:80>
DocumentRoot /domain1
ServerName www1.baidu.com
</VirtualHost>
<VirtualHost 172.18.43.102:80>
DocumentRoot /domain2
ServerName www2.baidu.com
</VirtualHost>
2.基于ip的:
</VirtualHost>
<VirtualHost 172.18.43.148:80>
DocumentRoot /ip1
</VirtualHost>
<VirtualHost 172.18.43.149:80>
DocumentRoot /ip2
</VirtualHost>
3.基于端口的:
</VirtualHost>
Listen 8080
Listen 8081
<VirtualHost *:8080>
DocumentRoot /port1
ServerName 172.18.43.146:8080
</VirtualHost>
<VirtualHost *:8081>
DocumentRoot /port2
ServerName 172.18.43.146:8081
</VirtualHost>

~
~

~
~

apche基于域名,ip,端口的配置的更多相关文章

  1. Apache基于域名、端口、IP的虚拟主机配置(Centos 6.5)

    虚拟主机:部署多个站点,每个站点,希望用不同的域名和站点目录,或者是不同的端口,不同的ip,需要虚拟主机功能.一句话,一个http服务要配置多个站点,就需要虚拟主机. 虚拟主机分类:基于域名.基于端口 ...

  2. Nginx--服务部署、基于域名的虚拟主机配置

    一.服务部署 1.预处理 安装CentOS ,配置hosts.静态IP.设置必要的安全参数等(略) 1-1.系统环境 [root@vnx ~]# cat /etc/redhat-release Cen ...

  3. CentOS 7运维管理笔记(8)----Apache基于域名的虚拟主机配置

    使用基于域名的虚拟主机配置是比较流行的方式,可以在同一个IP上配置多个域名并且都通过80端口访问. (1) 在网卡 eth0的第五个接口上配置 192.168.1.215 这个地址: (2) 配置/e ...

  4. Nginx总结(四)基于域名的虚拟主机配置

    前面讲了如何安装配置Nginx,大家可以去这里看看nginx系列文章:https://www.cnblogs.com/zhangweizhong/category/1529997.html 今天要说的 ...

  5. nginx配置基于域名、端口、IP的虚拟主机

    1.基于域名的虚拟主机: 绝大多数企业对外提供服务的网站使用的都是基于域名的主机,通过不同的域名区分不同的虚拟主机. 首先我们进入安装nginxd的目录下:/application/nginx-1.6 ...

  6. nginx基于域名的虚拟主机配置(本地分布式项目域名配置及测试方法)

    最有用的虚拟主机配置方式. 一个域名只能绑定一个ip地址,一个ip地址可以被多个域名绑定. 可以修改host文件实现域名访问. 前提:即使我们在nginx中配置基于域名的虚拟主机,也需要域名解析,即n ...

  7. Tomcat-8.5.23 基于域名和端口的虚拟主机

    下载tomcat yum install java -y cd /opt/ wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.23/b ...

  8. 【原创】Linux基础之测试域名IP端口连通性

    一 测试域名是否可达 1 ping # ping www.baidu.comPING www.a.shifen.com (220.181.112.244) 56(84) bytes of data.6 ...

  9. apache2 httpd 基于域名的虚拟主机配置 for centos6X 和debian-8

    全系统虚拟主机: for debian 系统的apache2 域名 虚拟主机

随机推荐

  1. heritrix1.14.4配置-没有add和change按钮的问题

    今天搞了下heritrix1.14.4在eclipse下的配置,根据http://www.360doc.com/content/10/0913/18/2793979_53385587.shtml教程, ...

  2. 使用DLL进行不同语言之间的调用(转)

    源:使用DLL进行不同语言之间的调用 __declspec(dllexport) 是告诉编译器用来导出函数的,在代码中不另作说明了. extern "C" 的意思就是用C的方式来导 ...

  3. UIResponder学习

    http://blog.csdn.net/jimzhai/article/details/23283515 UIResponder 介绍 UIResponder 这个类定义了很多用来处理响应和时间处理 ...

  4. 360路由器设置网段ip

    路由器设置->高级设置->修改路由器地址

  5. redhat在线安装chrome浏览器

    开始的时候是参考吹尽黄沙始到金的文章http://www.cnblogs.com/effective/archive/2012/03/18/2405189.html 1.创建一个文件/etc/yum. ...

  6. 今日头条视频Url嗅探

    1.打开http://toutiao.com/a6309254755004875010/,查看网页源代码获取videoid = 0425d8f0c2bb425d9361c0eb2eeb4f16 2.拼 ...

  7. python3中bytes与string的互相转换

    首先来设置一个原始的字符串, Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win32 Ty ...

  8. 一个a::before的写法

    #key_table table tr td a::before{//这是个a前面的蓝色小圆点    background: #48A7D9;    content: "";//这 ...

  9. 2.12. 后端 SQL 的可见性(Core Data 应用程序实践指南)

    上一节已经插入了数据,非常好.但是,我得更进一步.要知道里面究竟发生了什么,持久化存储区的数据有什么变化,生成了哪些查询语句.每次运行程序时,是否重复插入了对象. 有一个调试选项可以提供足够的信息,开 ...

  10. iOS 登陆之使用ShareSDK

    0. 概述 登陆要使用ShareSDK,可以实现多社交平台账号登陆,短信验证,并且都是永久免费的. 网址:www.mob.com 1.iOS 登陆之界面设置