Sharing Ilmu

Sharing for useful things

How To Configuration Multiple Webserver with Different Domain in one server ubuntu 20.04

In the preceding tutorial, I have discuss about Configuration multiple webserver with single domain at article How To Configuration Multiple Webserver in one server Linux ubuntu 20.04.  And in this tutorial I’ll discuss about how to configuration multiple webserver with different domain. I’ll Continue the previous configuration in How To Configuration Multiple Webserver in one server Linux ubuntu 20.04 for this article. For example we requires webserver with domain taufiknurhuda.com and myarchieve.net.  Make sure you have configured at the preceding article.

CONFIGURE DNS SERVER

Change the configuration zone :

root@Taufik:~# nano /etc/bind/named.conf.local

Add the configuration as the following.  see at zone 0.0.10, it’s the network for server ip 10.0.0.2 written in reverse.

//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

zone "taufiknurhuda.com" {
     type master;
     file "/etc/bind/db.domain";
};

zone "myarchieve.net" {
     type master;
     file "/etc/bind/db.archieve";
};
zone "0.0.10.in-addr.arpa" {
     type master;
     file "/etc/bind/db.ip";
};

 

Change directory to /etc/bind :

root@Taufik:~# cd /etc/bind/
root@Taufik:/etc/bind#

Copy  default db file configuration to new db file db.local to db.archieve.

root@Taufik:/etc/bind# cp db.local db.archieve

Configure db.domain :

root@Taufik:/etc/bind# nano db.archieve

Do configuration as the following :

;
; BIND data file for local loopback interface
;
$TTL     604800
@          IN           SOA          myarchieve.net. root.myarchieve.net. (
                                                2             ;  Serial
                                           604800             ; Refresh
                                            86400             ; Retry
                                          2419200             ; Expire
                                           604800 )           ; Negative Cache TTL
;
@          IN           NS            ns.myarchieve.net.
ns         IN            A                10.0.0.2
@          IN            A                10.0.0.2
www        IN            A                10.0.0.2

Edit the db.ip configuration :

root@Taufik:/etc/bind# nano db.ip

Add new configuration as the following bellow :

;
; BIND data file for local loopback interface
;
$TTL     604800
@          IN           SOA          taufiknurhuda.com. root.taufiknurhuda.com. (
                                                1             ;  Serial
                                           604800             ; Refresh
                                            86400             ; Retry
                                          2419200             ; Expire
                                           604800 )           ; Negative Cache TTL
;
@          IN           NS           ns.taufiknurhuda.com.
2         IN           PTR           taufiknurhuda.com.
2         IN           PTR           www.taufiknurhuda.com.
2         IN           PTR           portal.taufiknurhuda.com.
2         IN           PTR           ns.myarchieve.net.
2         IN           PTR           myarchieve.net.
2         IN           PTR           www.myarchieve.net.

 

Restart bind9 service :

root@Taufik:~# systemctl restart bind9.service

Test the dns configuration :

root@Taufik:/etc/bind# nslookup taufiknurhuda.com
Server: 10.0.0.2
Address: 10.0.0.2#53

Name: taufiknurhuda.com
Address: 10.0.0.2
root@Taufik:/etc/bind# nslookup myarchieve.net
Server: 10.0.0.2
Address: 10.0.0.2#53

Name: myarchieve.net
Address: 10.0.0.2
root@Taufik:/etc/bind# nslookup 10.0.0.2
2.0.0.10.in-addr.arpa name = taufiknurhuda.com.
2.0.0.10.in-addr.arpa name = www.taufiknurhuda.com.
2.0.0.10.in-addr.arpa name = myarchieve.net.
2.0.0.10.in-addr.arpa name = www.myarchieve.net.
2.0.0.10.in-addr.arpa name = ns.myarchieve.net.
2.0.0.10.in-addr.arpa name = ns.taufiknurhuda.com.
2.0.0.10.in-addr.arpa name = portal.taufiknurhuda.com.

Dns configuration is successfull.

CONFIGURE WEBSERVER

Change to sites-available directory :

root@Taufik:~# cd /etc/apache2/sites-available/
root@Taufik:/etc/apache2/sites-available#

Copy file conf :

root@Taufik:/etc/apache2/sites-available# cp 000-default.conf archieveweb.conf

Configure archieveweb.conf :

root@Taufik:/etc/apache2/sites-available# nano archieveweb.conf

Do the configuration like this :

<VirtualHost *:80>
              # The ServerName directive sets the request scheme, hostname and port that
              # the server uses to identify itself. This is used when creating
              # redirection URLs. In the context of virtual hosts, the ServerName
              # specifies what hostname must appear in the request's Host: header to
              # match this virtual host. For the default virtual host (this file) this
              # value is not decisive as it is used as a last resort host regardless.
              # However, you must set it for any further virtual host explicitly.
              # ServerName www.example.com

                 ServerAdmin admin@myarchieve.net
                 ServerName myarchieve.net
                 ServerAlias www.myarchieve.net
                 DocumentRoot /var/www/html/archieveweb

            # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
            # error, crit, alert, emerg.
            # It is also possible to configure the loglevel for particular
            # modules, e.g.
            #LogLevel info ssl:warn

              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
 

Enable the archieveweb.conf :

root@Taufik:/etc/apache2/sites-available# a2ensite archieveweb.conf

Restart apache2 service :

root@Taufik:~# systemctl restart apache2

Change Directory to /var/www/html :

root@Taufik:~# cd /var/www/html/
root@Taufik:/var/www/html#

 

Create the example html directories for archieveweb:

root@Taufik:/var/www/html# mkdir archieveweb
root@Taufik:/var/www/html# ls
archieveweb    index.html      info.php.    portalweb    primaryweb   
root@Taufik:/var/www/html#

Create the example html file in archieveweb directory :

root@Taufik:/var/www/html# echo "WECOME TO ARCHIEVE WEB" > archieveweb/index.html
 

Do local test the webserver with domain using curl.

Pay attention to the following :

root@Taufik:~# curl myarchieve.net
WELCOME TO ARCHIEVE WEB
root@Taufik:~#

Test from client :

Configuration is successfull.

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>