Last updated on August 28th, 2020 at 05:13 pm

In this tutorial I am going to explain to you how we can point a domain name to our website which was hosting in Apache server in simple steps.

Setup A Virtual Host in Apache server

Step 1. Hope you already installed Apache in your server. If not then please run below commands to do.

sudo apt-get update
sudo apt-get install apache2

Step 2. Now create your project in /var/www/html/ For now, I just create an index.html file in it and write hello.


Step 3. Now we can point a domain to our server I am using Cloudflare for that. In Cloudflare, you need to add a domain to your account then go to DNS setting and point the domain to your IP that’s it.

Step 4. Now go to /etc/apache2/sites-available and copy 000-default.conf and name that

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/

Step 5. Open copy file in the editor and make some required changes as shown below.

sudo nano /etc/apache2/sites-available/

After the file was open make changes or just copy below code and replace with yours.

<VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all

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

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.cgi index.html index.xhtml index.htm


Step 6. Now once you make changes in your file then you need to enable your website to do that run below command

sudo a2ensite

After that restart your Apache server

sudo systemctl restart apache2

and once your server is restarted you can open your website in the browser and get “helo” page.

Hope this simple ost helps you 🙂 .