久久国产乱子伦精品免费M,亚洲一区二区三区91,欧美国产在线视频,国产精品视频久久

linux網站中虛擬主機的實現

一臺Linux中網站虛擬主機的完成主要有三種方式:a、根據ip地址;b、根據端口號;c、根據域名。一下為完成進程:(本試驗的Linux虛機系統為rhel5.6)

1、基于域名的實現:

這種方式需要搭建dns域名服務器。

# cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

BOOTPROTO=static

IPADDR=192.168.22.133

NETWORK=192.168.22.0

NETMASK=255.255.255.0

BROADCAST=192.168.22.255

HWADDR=00:0C:29:89:05:2E

ONBOOT=yes

# cat /etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=no

HOSTNAME=httpd.com

# cat /etc/resolv.conf

nameserver 192.168.22.133

search httpd.com

#yum install httpd -y

# vim /etc/httpd/conf/httpd.conf

NameVirtualHost 192.168.22.133:80 ?#將這一行注釋符取消掉,*號改成ip地址

<VirtualHost 192.168.22.133:80> ? ? ? ? ? ? ? ? ? ? #復制粘貼即可得到以下幾行(nyy p)

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot /www/bbs

ServerName bbs.httpd.com

ErrorLog logs/dummy-host.example.com-error_log

CustomLog logs/dummy-host.example.com-access_log common

</VirtualHost>

<VirtualHost 192.168.22.133:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot /www/news

ServerName news.httpd.com

ErrorLog logs/dummy-host.example.com-error_log

CustomLog logs/dummy-host.example.com-access_log common

</VirtualHost>

#mkdir -p /www/{news,bbs}

#vim /www/news/index.html

news page here

#vim /www/bbs/index.html

hello ,this is bbs

#service network restart

#service httpd start

#yum install bind bind-chroot bind-utils caching-nameserver -y

#cd /var/named/chroot/etc

#cp -a named.caching-nameserver.conf ?named.conf

#vim named.conf

options {

listen-on port 53 { any; };

directory ? ? ? "/var/named";

dump-file ? ? ? "/var/named/data/cache_dump.db";

statistics-file "/var/named/data/named_stats.txt";

allow-query ? ? { any; };

allow-query-cache { any; };

};

zone "httpd.com" {

type master;

file "httpd.com.zone";

};

zone "22.168.192.in-addr.arpa" {

type master;

file "22.168.192.zone";

};

#cd ../var/named

#touch httpd.com.zone

#touch 22.168.192.zone

#cat localhost.zone > httpd.com.zone

#cat named.local > 22.168.192.zone

#vim httpd.com.zone

$TTL ? ?86400

@ ? ? ? ? ? ? ? IN SOA ?@ ? ? ? root (

42 ? ? ? ? ? ? ?; serial (d. adams)

3H ? ? ? ? ? ? ?; refresh

15M ? ? ? ? ? ? ; retry

1W ? ? ? ? ? ? ?; expiry

1D ) ? ? ? ? ? ?; minimum

IN NS ? ? ? ? ? @

IN A ? ? ? ? ? ?192.168.22.133

bbs ? ? ? ? ? ? IN A ? ? ? ? ? ?192.168.22.133

news ? ? ? ? ? ?IN A ? ? ? ? ? ?192.168.22.133

#vim 22.168.192.zone

$TTL ? ?86400

@ ? ? ? IN ? ? ?SOA ? ? localhost. root.localhost. ?(

1997022700 ; Serial

28800 ? ? ?; Refresh

14400 ? ? ?; Retry

3600000 ? ?; Expire

86400 ) ? ?; Minimum

IN ? ? ?NS ? ? ?httpd.com.

133 ? ? ? IN ? ? ?PTR ? ? bbs.http.com.

133 ? ? ? IN ? ? ?PTR ? ? news.http.com.

#service named start

# host bbs.httpd.com

bbs.httpd.com has address 192.168.22.133

# host news.httpd.com

news.httpd.com has address 192.168.22.133

# host 192.168.22.133

133.22.168.192.in-addr.arpa domain name pointer news.http.com.

133.22.168.192.in-addr.arpa domain name pointer bbs.http.com.

在Linux自帶的火狐瀏覽器測試,如下圖:

linux網站中虛擬主機的實現

在另外一臺虛擬的xp系統上面測試:(此時的Linux和xp虛機均為橋接方式),如下圖

linux網站中虛擬主機的實現

ok,到此為止,Linux下http域名虛擬主機的配置完美結束。

2、基于ip地址的實現

#cp ifcfg-eth0 ifcfg-eth0:1

#cp ifcfg-eth0 ifcfg-eth0:2

# cat ifcfg-eth0:1

DEVICE=eth0:1

BOOTPROTO=static

IPADDR=192.168.22.134

NETWORK=192.168.22.0

NETMASK=255.255.255.0

BROADCAST=192.168.22.255

HWADDR=00:0C:29:89:05:2E

ONBOOT=yes

# cat ifcfg-eth0:2

DEVICE=eth0:2

BOOTPROTO=static

IPADDR=192.168.22.135

NETWORK=192.168.22.0

NETMASK=255.255.255.0

BROADCAST=192.168.22.255

HWADDR=00:0C:29:89:05:2E

ONBOOT=yes

#service network restart

#vim /etc/httpd/conf/httpd.conf

<VirtualHost 192.168.22.133:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot /www/133

ServerName 192.168.22.133

ErrorLog logs/dummy-host.example.com-error_log

CustomLog logs/dummy-host.example.com-access_log common

</VirtualHost>

<VirtualHost 192.168.22.134:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot /www/134

ServerName 192.168.22.134

ErrorLog logs/dummy-host.example.com-error_log

CustomLog logs/dummy-host.example.com-access_log common

</VirtualHost>

<VirtualHost 192.168.22.135:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot /www/135

ServerName 192.168.22.135

ErrorLog logs/dummy-host.example.com-error_log

CustomLog logs/dummy-host.example.com-access_log common

</VirtualHost> ? ? ? ? ? ? ? ? ? ? ? ? #要把NameVirtualHost關掉

#mkdir -p /www/{133,134,135}

# cat /www/133/index.html

hello ,this is 133 page.

# cat /www/134/index.html

hi ,this is 134 index

# cat /www/135/index.html

hey,this is 135 index page

#service httpd restart

到此,打開Linux自帶的火狐瀏覽器瀏覽,如下圖所示:

linux網站中虛擬主機的實現

基于ip地址的虛擬主機搭建成功。

3、基于端口的實現:

首先要手工配置一個ip地址,本實驗使用的地址為192.168.22.133,改地址怎樣配置見方式1詳解。

#vim /etc/httpd/conf/httpd.conf

Listen 80

Listen 8080

Listen 8081 ? ? ? ?#在Listen下面添加下面兩行

。。。。

<VirtualHost 192.168.22.133:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot /www/80

ServerName 192.168.22.133

ErrorLog logs/dummy-host.example.com-error_log

CustomLog logs/dummy-host.example.com-access_log common

</VirtualHost>

<VirtualHost 192.168.22.133:8080>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot /www/8080

ServerName 192.168.22.133

ErrorLog logs/dummy-host.example.com-error_log

CustomLog logs/dummy-host.example.com-access_log common

</VirtualHost>

<VirtualHost 192.168.22.133:8081>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot /www/8081

ServerName 192.168.22.133

ErrorLog logs/dummy-host.example.com-error_log

CustomLog logs/dummy-host.example.com-access_log common

</VirtualHost>

#mkdir -p /www/{80,8080,8081}

# cat /www/80/index.html

this is port 80 page

# cat /www/8080/index.html

this is port 8080 test page

# cat /www/8081/index.html

hello, this is port 8081 page

#service httpd restart

到此用Linux自帶的火狐瀏覽器測試一下,如下圖所示:

linux網站中虛擬主機的實現

到此,根據端口方法的方式裝備成功。
到此為止,Linux網站虛擬主機的三種裝備方法裝備結束。

 

馬哥教育-Linux學習-1群 485374463

馬哥教育-Linux學習-2群 339184057

 

相關新聞

歷經多年發展,已成為國內好評如潮的Linux云計算運維、SRE、Devops、網絡安全、云原生、Go、Python開發專業人才培訓機構!

    1. 主站蜘蛛池模板: 建湖县| 铜梁县| 姜堰市| 冕宁县| 永昌县| 天门市| 香格里拉县| 泗水县| 宁安市| 从江县| 五常市| 玛曲县| 泰州市| 深圳市| 建水县| 专栏| 女性| 喀喇| 新闻| 苏尼特右旗| 高唐县| 孝昌县| 胶州市| 丽水市| 肃宁县| 靖远县| 兴业县| 丹江口市| 莱州市| 罗城| 万盛区| 光泽县| 卓尼县| 友谊县| 巩留县| 莲花县| 福建省| 余干县| 桓台县| 湖北省| 沙田区|