How to install your own Ubuntu 20.04 Linux server | Part 5 of 10

linux hetzner cloud virtual server tutorial

In Part 5 of the tutorial we'll buy a domain and point it to the Hetzner Server and create a Virtual Host for domain and check if it's online.

It's recommended that you have read the previous steps of this course. You'll find the overview at the end of this blogpost.

Course ingredients:

10. Buy Domain and point it to Hetzner Server

I have domains at different providers. The one I'm going to point at Hetzner Server was bought at The Domain name is An eCommerce website I'm building in the third quarter of this year. If you like the japanese culture: they'll import hand selected items from Japan to the European market.

Setting the A-Record for and


@ stands for the origin which in this case is the first level domain:

11. Create Virtual Host for domain

Navigate into the web directory:
cd /var/www/

Creating a root directory for the website:
sudo mkdir -p

Navigate into the new directory:
cd /var/www/

Create an index.html file which will show some content on your website:
sudo touch index.html

Open the file in the nano editor:
sudo nano index.html
Type: Hello World!


Save and close nano:
ctrl + o, press enter, ctrl + x


Open the file to check that you have saved the content:
cat index.html


Give recursive permissions to all data inside the root directory to Apache2 web server so it will show via http in the browser:
sudo chown -R www-data: /var/www/


Navigate into the apache directory for available sites:
cd /etc/apache2/sites-available/

Create a file:
sudo touch

Open the file in the nano editor:
sudo nano

Copy and paste the content of the following code block and replace it with your specific domain names:

<VirtualHost *:80>  
    DocumentRoot /var/www/  

    <Directory /var/www/>  
        Options -Indexes +FollowSymLinks  
        AllowOverride All  

    ErrorLog ${APACHE_LOG_DIR}/  
    CustomLog ${APACHE_LOG_DIR}/ combined  

ServerName: This should be your domain name.
ServerAlias: Additional domains or subdomains such as www subdomain.
DocumentRoot: The root directory from which Apache2 serves the files to the web.
Options: Server features that are available for a specific directory.
-Indexes: Prevents directory listings.
FollowSymLinks: Symbolic links are like shortcuts or references to the actual file or directory. AllowOverride: Specifies what the .htaccess file is allowed to override in the configuration.
ErrorLog, CustomLog: Specifies the location for log files.


Now enable the new virtual host file:
sudo a2ensite

The a2ensite helper script creates a symbolic link from the virtual host file to the sites-enabled directory.

Restart your apache2 service:
systemctl reload apache2


Check your domain in the browser. It should show the content of your index file: Hello World!

The Course Syllable:

22.05.2021 – Part 1

  1. Introduction & reasoning

29.05.2021 – Part 2

  1. Create Hetzner Cloud Server
  2. Connect to Server

05.06.2021 – Part 3

  1. Update and upgrade Ubuntu installation and install apache2
  2. Install PHP

12.06.2021 – Part 4

  1. Establish ssh keys
  2. Add new sudo user
  3. Deactivate root user
  4. Make new sudo user owner of ssh service

19.06.2021 – Part 5

  1. Buy Domain and point it to Hetzner Server
  2. Create Virtual Host for domain

26.06.2021 – Part 6

  1. Get free Let's Encrypt SSL certificates
  2. Request certificate, active https and force SSL

03.07.2021 – Part 7

  1. Install Git on Remote Server
  2. Create CI/CD user and ssh keys for Gitlab on Remote Server

10.07.2021 – Part 8

  1. Create Gitlab Repository
  2. Establish ssh keys and configure CI/CD

17.07.2021 – Part 9

  1. Install MySQL
  2. Install phpMyAdmin

24.07.2021 – Part 10

  1. Summary of project development workflow
  2. I'll be back – The course update log

See you next week for more


Previous Post Next Post

This site uses cookies to store information on your computer. Some of these cookies are essential, while others help us to improve your experience by providing insights into how the site is being used. ×
Necessary Cookies

Necessary cookies enable core functionality such as page navigation and access to secure areas. The website cannot function properly without these cookies, and can only be disabled by changing your browser preferences.

Analytical Cookies

Analytical cookies help us to improve our website by collecting and reporting information on its usage.

Marketing cookies

We use marketing cookies to help us improve the relevancy of advertising campaigns you receive.