Mandrake10.0下配置Apache+Named虚拟主机

Mandrake10.0下配置Apache+Named虚拟主机

系统:Mandrake10.0

1. apache的安装和配置:
到64.123或者apache的官方主页上下载一个httpd-2.0.50.tar.gz,依次
#tar xvzf httpd-2.0.50.tar.gz
#./configure --prefix=/www/apache;make;make install
编辑/www/apache/conf/httpd.conf,做了其它基本配置之后,到文件的section3,修改如下,添加两个虚拟主机:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *:80>
ServerAdmin linuxidc@linuxidc.com
DocumentRoot /www/apache/htdocs
ServerName
ErrorLog logs/www.linuxidc.com-error_log
CustomLog logs/www.linuxidc.com-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin sunshine@ustc.edu
DocumentRoot /www/apache/sunshinedocs
ServerName sunshine.infonet.org
ErrorLog logs/sunshine.infonet.org-error_log
CustomLog logs/sunshine.infonet.org-access_log common
</VirtualHost>

保存退出,然后在/www/apache/htdocs和/www/apache/sunshinedocs添加不同的主页文件,最后:
#/www/apache/bin/apachectl start
启动httpd
2. named的安装配置
我的linux是ftp安装的,因此只要用下面这条命令就给我把named装上了,很简单。
#urpmi name
编辑/etc/named.conf,在options字段添加:
forward first;
forwarders {
202.38.64.1;
};
再添加如下语句:
zone "infonet.org" {
type master;
file "name2ip.db";
allow-update {localhost;};
};

保存退出。然后在/var/named/下添加一文件name2ip.db,编辑内容为:
$TTL 86400
@ IN SOA root. (
2001111601
28800
14400
3600000
86400
)

IN NS
IN A 192.168.3.153

kingpaul IN A 192.168.3.153
sunshine IN A 192.168.3.153
jbhuang IN A 192.168.3.69
lab IN A 192.168.3.1
localhost A 127.0.0.1

然后,编辑/etc/resolv.conf,添加字段
search infonet.org
servername 192.168.3.153
最后:
#serice named restart
启动named

3. 在另外一台机器上,将DNS服务器设置为192.168.3.153,nslookup 和nslookup linuxidc.com发现两者地址是一样的,打开IE,地址敲和linuxidc.com,可打开不同的主页,虚拟主机设置成功。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyfpds.html