• PHPdns代码仓库:https://github.com/helloxz/phpdns/

    编辑application/helpers/check_helper.php设置用户名、密码
    填坑
    页面application/views/admin.php中的菜单链接错误,需将list改为listrecord
    如:<a href="/admin/listrecord/hosts/0">hosts列表</a>

  • Nginx伪静态

    location ^~ /application {
          deny all;
    }
    location ^~ /system {
          deny all;
    }
    location ^~ /(application|system) {
          deny all;
    }
    location / {
      try_files $uri $uri/ /index.php?$query_string;
    }
  • 建立软链接

    ln -s /home/wwwroot/dns.local/application/conf/hosts.conf /etc/dnsmasq.d/hosts.conf
    ln -s /home/wwwroot/dns.local/application/conf/adblock.conf /etc/dnsmasq.d/adblock.conf    
  • 定时shell脚本reload.sh

    #!/bin/bash
    find /home/wwwroot/dns.local/application/conf/ -name '*.conf' -mmin -1 -exec /bin/systemctl restart dnsmasq.service {} \;

    赋予执行权限 chmod +x reload.sh,添加定时任务*/1 * * * * /root/reload.sh

  • 查看dnsmasq状态
xxx@debian-local:~# systemctl status dnsmasq.service -l
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled)
  Drop-In: /run/systemd/generator/dnsmasq.service.d
           └─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf
   Active: active (running) since 一 2018-12-23 09:51:01 CST; 1min 21s ago
  Process: 22015 ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconf (code=exited, status=0/SUCCESS)
  Process: 22032 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
  Process: 22025 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
  Process: 22022 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
 Main PID: 22031 (dnsmasq)
   CGroup: /system.slice/dnsmasq.service
           └─22031 /usr/sbin/dnsmasq -x /var/run/dnsmasq/dnsmasq.pid -u dnsmasq -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service --trust-anchor=.,19036,8,2,49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5 --trust-anchor=.,20326,8,2,e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d

12月 23 09:51:01 debian-local dnsmasq[22022]: dnsmasq: syntax check OK.
12月 23 09:51:01 debian-local dnsmasq[22031]: started, version 2.72 cachesize 150
12月 23 09:51:01 debian-local dnsmasq[22031]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect
12月 23 09:51:01 debian-local dnsmasq[22031]: DNS service limited to local subnets
12月 23 09:51:01 debian-local dnsmasq[22031]: reading /etc/resolv.conf
12月 23 09:51:01 debian-local dnsmasq[22031]: using nameserver 192.168.24.2#53
12月 23 09:51:01 debian-local dnsmasq[22031]: read /etc/hosts - 5 addresses
12月 23 09:51:01 debian-local systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.