Install apache2 server with mod_ssl and dedicated subdomain

First install apache2 webserver firing following command on your terminal:

sudo apt-get install apache2
Step 1 : Create a “.conf ” file in sites-available. 
cd /etc/apache2/sites-available
Step 2 :
Insert following content in :  
<VirtualHost *:80>
        ServerAdmin        //your server email id
        ServerName      //your domain name
        ServerAlias  // alias if you want its optional
        DocumentRoot /var/www/testfolder/   //your root folder if default no change needed
<Directory "/var/www/testfolder">
        AuthType Basic
        AuthName "test"
        AuthUserFile /var/www/testfolder/passwords
        Require valid-user test
 Step 3 : Enabling the domain
$sudo service apache2 reload
Step 4 : Enable mod_ssl or https feature for your domain name
$sudo a2enmod ssl           // it will enable mod_ssl feature
$sudo a2ensite default-ssl  //it will configure apache2 for https
$sudo service apache2 restart
Note : If you want to add a certificate for your website you can change the path in /etc/apache2/sites-available/default-ssl.conf
 Step 5 : Configure DNS resolution for the new hostname  


  • If you are just playing with this locally and do not want to create a “real” DNS entry, you have to edit the file /etc/hosts so that your computer can resolve the hostname to an IP address.
  • If you are running the web server on the same machine as the browser, you will want to map to
  •  If the browser is on a different machine on your local network, you’ll need to determine the server’s IP address and then on the browser machine, edit /etc/hosts to add the mapping.
  • For Windows, the file is called C:/windows/system32/drivers/etchosts
  •  A sample entry would be (for the browser running on the same machine as the server):

If the server is at, say, the entry would be:
  • If the server has a real routable IP address, then if you want the address to resolve on the global Internet you will have to get your service provider to add it to DNS. For testing purposes, you can still use /etc/hosts as described above. Just substitute the server’s real IP instead of Do this on the system where you are running the browser.

Blogger & Assc Cloud Architect

Site Footer

%d bloggers like this: