I have a domain betasquirrel.com
purchased from GoDaddy and a VPS with Ubuntu 16.04. And I hosted the domain successfully using BIND9 as below:
Created virtual-host for betasquirrel.com
in Apache and placed the files. Next created two hosts ns1.betasquirrel.com
and ns2.betasquirrel.com
in GoDaddy by pointing to VPS IP address.
Next configured BIND9,
/etc/bind/zones/master/db.betasquirrel.com
;
; BIND data file for betasquirrel.com
;
$TTL 3h
@ IN SOA ns1.betasquirrel.com. admin.betasquirrel.com. (
1 ; Serial
3h ; Refresh after 3 hours
1h ; Retry after 1 hour
1w ; Expire after 1 week
1h ) ; Negative caching TTL of 1 day
;
@ IN NS ns1.betasquirrel.com.
@ IN NS ns2.betasquirrel.com.
betasquirrel.com. IN MX 10 mail.betasquirrel.com.
betasquirrel.com. IN A 144.217.163.139
ns1 IN A 144.217.163.139
ns2 IN A 144.217.163.139
www IN CNAME betasquirrel.com.
mail IN A 144.217.163.139
ftp IN CNAME betasquirrel.com.
/etc/bind/zones/master/db.144.217.163
;
; BIND reverse data file for 163.217.144.in-addr.arpa
;
$TTL 604800
163.217.144.in-addr.arpa. IN SOA ns1.betasquirrel.com. admin.betasquirrel.com. (
1 ; Serial
3h ; Refresh after 3 hours
1h ; Retry after 1 hour
1w ; Expire after 1 week
1h ) ; Negative caching TTL of 1 day
;
163.217.144.in-addr.arpa. IN NS ns1.betasquirrel.com.
163.217.144.in-addr.arpa. IN NS ns2.betasquirrel.com.
139.163.217.144.in-addr.arpa. IN PTR betasquirrel.com.
/etc/bind/named.conf.local
zone "betasquirrel.com" {
type master;
file "/etc/bind/zones/master/db.betasquirrel.com";
};
zone "163.217.144.in-addr.arpa" {
type master;
file "/etc/bind/zones/master/db.144.217.163";
};
In named.conf.options
forwarders {
213.186.33.99;
};
/etc/init.d/bind9 restart
Next added the name-servers ns1.betasquirrel.com
and ns2.betasquirrel.com
in GoDaddy and the site started working.
Now how can I host sub-domains like demo.betasquirrel.com
. I have just created virtual-hosts and it's not working.
/etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
search demo.betasquirrel.com
search betasquirrel.com
nameserver 213.186.33.99
search local
/etc/apache2/sites-available/betasquirrel.com.conf
<VirtualHost *:80>
ServerName betasquirrel.com
ServerAlias www.betasquirrel.com
DocumentRoot /var/www/html/betasquirrel.com/htdocs
DirectoryIndex index.php index.html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/apache2/sites-available/demo.betasquirrel.com.conf
<VirtualHost *:80>
ServerName demo.betasquirrel.com
ServerAlias www.demo.betasquirrel.com
DocumentRoot /var/www/html/demo.betasquirrel.com/htdocs
DirectoryIndex index.php index.html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>