美文网首页
centos7 下 dns,apache配置

centos7 下 dns,apache配置

作者: 082e63dc752b | 来源:发表于2019-06-15 00:42 被阅读0次
  1. 配置光盘为本地yum源

     #创建临时挂载目录
     [root@localhost ~]# mkdir /mnt/cdrom
     #挂载光盘到临时挂载目录下
     [root@localhost ~]# mount /dev/cdrom /mnt/cdrom
     #进入到yum配置目录
     [root@localhost Packages]# cd /etc/yum.repos.d/
     [root@localhost yum.repos.d]# ll
     #建立备份文件夹
     [root@localhost yum.repos.d]# mkdir bak
     #将原来的yum源配置文件全部移动到备份文件夹下
     [root@localhost yum.repos.d]# mv  *  ./bak
     [root@localhost yum.repos.d]# ll
     #新建一个本地源文件
     [root@localhost yum.repos.d]# vi  local.repo
    
     #修改文件内容如下:
    
     [local_server]
     name = this is local repo
     baseurl = file:///mnt/cdrom
     enabled = 1
     gpgcheck = 0
    
     #更新yum源
     [root@localhost yum.repos.d]# yum list
    
  2. 安装并配置dns服务

     #安装dns
     [root@localhost ~]# yum install -y bind
     [root@localhost ~]# yum install -y bind-utils
     [root@localhost ~]# yum install -y bind-libs
     #安装apache
     [root@localhost ~]# yum install -y httpd
     #配置
     [root@localhost ~]# vi /etc/named.conf 
          12 options {
          13         listen-on port 53 { any; };
          14         listen-on-v6 port 53 { ::1; };
          15         directory       "/var/named";
          16         dump-file       "/var/named/data/cache_dump.db";
          17         statistics-file "/var/named/data/named_stats.txt";
          18         memstatistics-file "/var/named/data/named_mem_stats.txt";
          19         recursing-file  "/var/named/data/named.recursing";
          20         secroots-file   "/var/named/data/named.secroots";
          21         allow-query     {any; };
     #修改第13行和21行中括号内的内容为any;
     #文件末尾添加如下内容
          61 
          62 zone "test001.com"  {
          63         type master;
          64         file "test001.com.zone";
          65         allow-update {none;};
          66 };      
    # 复制一份域名zone文件并修改
     [root@localhost ~]# cp -p /var/named/named.localhost /var/named/test001.com.zone
     [root@localhost ~]# vi /var/named/test001.com.zone 
     #修改为如下内容:
     TTL 1D
     @       IN SOA  test001.com. admin.test001.com.  (
                                     0       ; serial
                                     1D      ; refresh
                                     1H      ; retry
                                     1W      ; expire
                                     3H )    ; minimum
               NS      @
               A       127.0.0.1
               AAAA    ::1
     www     IN      A       192.168.224.129
     
     #关闭防火请
     [root@localhost ~]# systemctl stop firewalld
     #关闭selinux
     [root@localhost ~]# vi /etc/selinux/config 
    # 修改如下内容:
     7 SELINUX=enforcing
     #为
     7 SELINUX=disabled
     #重启虚拟机
     [root@localhost ~]#  shutdown  -r  now
     #启动dns服务并测试dns
     [root@localhost ~]# service named restart
     [root@localhost ~]# nslookup  www.test001.com
     Server:     192.168.224.129
     Address:    192.168.224.129#53
    
     Name:   www.test001.com
     Address: 192.168.224.129
    

PS:
如果发生错误
可以查看 /var/log/messages
更改权限 chown named.named test001.com.zone

  1. 安装并配置apache服务
    #由于虚拟机重启过,需要重新挂载光盘
    [root@localhost ~]# mount /dev/cdrom /mnt/cdrom
    #安装apache
    [root@localhost ~]# yum install -y httpd
    #配置apache
    [root@localhost ~]# vi /etc/httpd/conf/httpd.conf 
    #修改第95行为如下样子:
    93 # If your host doesn't have a registered DNS name, enter its IP address here.
    94 #
    95 ServerName www.test001.com:80
    96 
    97 #
    #创建主页文件
    [root@localhost ~]# vi /var/www/html/index.html 
    #添加内容如下:
    <html>
            <body>
                    <h1>Hello world!</h1>
            </body>
    </html>
    #安装linux字符界面下网页浏览器
    [root@localhost ~]# yum install -y lynx
    #浏览网站
    [root@localhost ~]# lynx  www.test001.com

windows测试并浏览网站
修改c:\windows\system32\drivers\etc\hosts文件
添加一行

    192.168.224.129    www.test001.com

浏览器打开 www.test001.com,看是否访问正常

相关文章

网友评论

      本文标题:centos7 下 dns,apache配置

      本文链接:https://www.haomeiwen.com/subject/qykvfctx.html