基于域名的服务端:
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. Laravel 使用简述

    开始使用laravel 在此之前我们需要修改一些配置: app/config/app.php 文件中的 debug 选项设置为 true (注:开启开发模式,更友好的开发提示:网站运行时则关闭): a ...

  2. webstorm安装express报错

    .... Exit code: -1 解决方法: webstorm创建express 需要 预先安装express-generator npm install express-generator -g

  3. STM32驱动MPU6050

    轴 MEMS轴 MEMS 加速度计,以及一个可扩展的数字运动处理器 DMP(Digital Motion Processor),可用 I2C 接口连接一个第三方的数字传感器,比如磁力计.扩展之后就可以 ...

  4. PHP实反向代理-收藏

    需求 现在有些后辍的域名不支持备案,这个时候需要用免备案主机或空间做个反向代理,这样可实现内容存放在国内主机统一管理 实现 用 php-dynamic-mirror 可实现,并在头部进行域名转换,可实 ...

  5. 蓝牙协议 基于TI cc2540 模块的理解(转)

    源:蓝牙协议 基于TI cc2540 模块的理解 Bluetooth 4.0开发 Platform:TI IC:cc2540 Environment:windows 7 tools:IAR 8.20. ...

  6. NSString总结

    [from]http://www.jianshu.com/p/7994b0ad6b88 问题:NSString到底是不是字符串? NSString 是 OC中专门处理字符串的对象!提供了转换大小写,拼 ...

  7. 设置MyEclipse黑色主题背景

    设置MyEclipse黑色主题背景 1. 下载 http://eclipsecolorthemes.org/  看哪个合适直接点击进入, 下载右边的epf 2. 下载完成...打开myeclipse. ...

  8. leangoo

    leangoo网址:https://www.leangoo.com/

  9. IM 融云 之 列表及封装

    // // ChatListIMViewController.m // testRongCloudIM // // Created by WoodGao on 16/1/8. // Copyright ...

  10. IM 之 融云

    官方网站:http://www.rongcloud.cn 官方开发文档:http://www.rongcloud.cn/docs/ IM 融云 之 开发基础概念 IM 融云 之 通讯能力库API IM ...