学习笔记之使用域名创建虚拟主机

分两部分来实现

一、域名服务器

hosts--> DNS

    hosts:
        数据容易被个人修改出错
        数据容易不一致
        当数据庞大的时候维护麻烦

DNS域名解析体系的特点:
        数据不容易随便让人修改出错
        数据一致
        域名体系采用分层结构

    www.baidu.com. <----FQDN
        cn
        net
        org
        gov
        edu
        bz
        cc
        tv
        la   

linux默认的DNS服务器端软件
bind         服务端软件
bind-chroot    安全软件

    协议:DNS
    端口:udp:53  tcp:53


准备:
    1、本机的主机名必须是FQDN
    2、关闭selinux,iptables
    3、正确的时间(同步时间)
        ntpdate 10.1.1.1
配置文件存放的路径:
bind-chroot之前   
    /var/named  <---数据文件
    /etc/named.conf <---主配置文件
bind-chroot之后
    /var/named/chroot/var/named 
    /var/named/chroot/etc/named.conf


配置过程:
    1、主配置文件named.conf(增加你要管理的域名的定义)
    2、区域文件(域名的数据文件)
    3、重启服务


例子1:正向解析 name-->ip
1、
# vim /var/named/chroot/etc/named.conf
options {
        directory "/var/named";
        forwarders { 10.1.1.1; };

};


zone "wych.com" IN {
         type master;     #类型: slave,forward,hint
         file "data/master.wych.com.zone";
         allow-transfer { 10.1.1.253; };

};

zone "888.com" IN {
         type master;     #类型: slave,forward,hint
         file "data/master.888.com.zone";
         allow-transfer { 10.1.1.253; };

};


zone "1.1.10.in-addr.arpa" IN {
        type master;
        file "data/master.1.1.10.in-addr.arpa.zone";
};

 

 

 

 

 

2、vi /var/named/chroot/var/named/data/master.wych.com.zone

 


$TTL 86400
@       IN      SOA     wych.com.       root. (
                                        2010072101
                                        1M
                                        30
                                        1D
                                        1H                                                                              )
@       IN      NS      host.wych.com.
host    IN      A       10.1.1.101
www     IN      A       10.1.1.252
dns     IN      A       10.1.1.253
wych    IN      CNAME   host
@       IN      MX 10   mail.wych.com
mail    IN      CNAME   host



web     IN      A       10.1.1.101
web     IN      A       10.1.1.102
web     IN      A       10.1.1.103
web     IN      A       10.1.1.104
*       IN      A       10.1.1.101


$GENERATE 1-10 station$       IN      A       10.1.1.$

wych.com. IN     A       10.1.1.101

3、vi /var/named/chroot/var/named/data/master.888.com.zone

$TTL 86400
@       IN      SOA     888.com.        root. (
                                        2010072101
                                        1M
                                        30
                                        1D
                                        1H                                                                              )
@       IN      NS      ftp.888.com.
ftp     IN      A       10.1.1.101

 

 

4、 vi /var/named/chroot/var/named/data/master.1.1.10.in-addr.arpa.zone

 

@       IN      SOA     1.1.10.in-addr.arpa.    root. (
                                        2010072102
                                        60
                                        30
                                        1D
                                        1H )

@       IN      NS      host.wych.com.
101     IN      PTR     host.wych.com.
252     IN      PTR     www.wych.com.
253     IN      PTR     dsn.wych.com


$GENERATE 1-10  $ IN PTR stationi$.wych.com

 

 

5、service named restart  

或者  /etc/init.d/named restart

 

 

二、apache配置步骤

apache
   
    网页技术:
        静态:.html .htm
        动态:.asp .aspx .php .jsp .cgi

    web服务器端:
        windows : IIS 
        Linux/Unix: apache , tomcat ,jboss , nginx

    协议: http ,https
    端口:80 , 443

========================================================

软件包:
    httpd
    httpd-devel
工作目录: /etc/httpd/
配置目录:/etc/httpd/conf/httpd.conf
    /etc/httpd/conf.d/*.conf   


启动报错:

[root@squid ~]# service httpd restart
停止 httpd:                                               [确定]
启动 httpd:httpd: apr_sockaddr_info_get() failed for squid.upl.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                           [确定]
提示:
hosts
配置文件:ServerName 10.1.1.21



核心参数的说明:

DocumentRoot "/var/www/html"  《---网站的根目录


DirectoryIndex index.html index.htm default.htm default.html index.html.var index.php default.php 《--定义默认首页



<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None <---是否支持口令验证
    Order allow,deny <---访问控制
    Allow from all
</Directory>

1、 vim /etc/httpd/conf/httpd.conf

 

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# 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 webmaster@wych.wych.com
    DocumentRoot /www
    ServerName wych.wych.com
    ErrorLog logs/wych.wych.com-error_log
    CustomLog logs/wych.wych.com-access_log common
</VirtualHost>
   

<VirtualHost *:80>
    ServerAdmin webmaster@ftp.888.com
    DocumentRoot /ftp
    ServerName ftp.888.com
    ErrorLog logs/ftp.wych.com-error_log
    CustomLog logs/ftp.wych.com-access_log common
</VirtualHost>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值