Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

centos环境下的apache 2.4虚拟主机的三种实现方法

$
0
0

呐,苦于没法在生产环境使用apache,呐呐呐,虚拟机!

方法一:基于IP

IP1:80

IP2:80

方法二:基于端口

IP:80

IP:8080

方法三:基于域名

IP:80

主机名不同

www.abcd.com

www.efgh.com

一、基于IP

1、配置第二地址

[ root@localhost ~]#cd/etc/sysconfig/network-scripts/ [ root@localhost network-scripts]#cpifcfg-eth0ifcfg-eth0:0
centos环境下的apache 2.4虚拟主机的三种实现方法
[ root@localhost

network-scripts]#servicenetworkrestart


centos环境下的apache 2.4虚拟主机的三种实现方法

#Virtualhosts

Include/etc/httpd/extra/httpd-vhosts.conf

3、配置httpd-vhosts.conf


centos环境下的apache 2.4虚拟主机的三种实现方法

4、建立网页目录a.org及zjj


centos环境下的apache 2.4虚拟主机的三种实现方法

5、新建网页文件


centos环境下的apache 2.4虚拟主机的三种实现方法

6、用elinks打开网页

[ root@localhost htdocs]#elinks http://192.168.1.135
centos环境下的apache 2.4虚拟主机的三种实现方法
[ root@localhost htdocs]#elinks

http://192.168.1.136


centos环境下的apache 2.4虚拟主机的三种实现方法

二、基于端口(注意:iptables放行8080端口)

1、修改httpd.conf


centos环境下的apache 2.4虚拟主机的三种实现方法
2、 修改

httpd-vhosts.conf


centos环境下的apache 2.4虚拟主机的三种实现方法

3 、新建网页目录及网页文件


centos环境下的apache 2.4虚拟主机的三种实现方法

4、测试

[root@localhosthtdocs]#elinkshttp://192.168.1.135
centos环境下的apache 2.4虚拟主机的三种实现方法
[ root@localhost htdocs]#elinks http://192.168.1.135:8080
centos环境下的apache 2.4虚拟主机的三种实现方法

三、基于域名

看到空白的,肯定要嫌我懒了。。 基于域名基本与前面一直,只要修改hosts文件,能让域名解析到即可。


Viewing all articles
Browse latest Browse all 11063

Trending Articles