How To Configure Apache Virtual Hosts In Ubuntu 18.04 LTS

Configure Apache Virtual Hosts In Ubuntu

17 Responses

  1. Sean says:

    Hope you cover enabling ssl via virtual hosts. I have 6 websites and all but one is working right. One works on port 80 but when I try https it goes to a different site. Any pointers?

  2. Bruce says:

    I would leave the default.conf enabled for when someone just enters the bare ip address and have it handle that case.

  3. Ruben says:

    I saw this on a few sites but what do you do with the DNS now?
    Just point 2 domains to one ip? That did not work for me.

  4. Leon says:

    I’ve been creating my VH folders in www and naming them for example, ostechnix.lan
    I’ve also been adding my $USER to www-data and then doing sudo chown -R $USER:www-data …
    Is this bad?

  5. I’m using Ubuntu 18.04 and have followed your direction but I can only get lrobin1.lan. I have gone over and over everything I still can not find out why I only get one.

    • Scallywag says:

      change the host file on your remote computer also to reflect the two hosts. ostechnix1.lan ostechnix2.lan
      in windows it is found in /windows/system32/drivers/etc/host.
      just open and add those same two lines. then you can access both by typing http://ostechnix1 (or 2) and hitting enter

  6. Stan says:

    What should be the permissions for new directories ?

  7. Charles says:

    You should then install Certbot and enable SSL – The script will prompt you to set up SSL for each configured website.

  8. simon says:

    Hi there,
    Thanks for sharing this post,
    is very helpful article.

  9. ubi says:

    I’m new to terminal and coding how do you save the file after you Create demo web pages for each host? I add the then I cant save it.

    • Tudor says:

      You can simply Ctrl + X (to exit the file) and it asks if you want to save it, so you press Y and it asks you what name do you want to give to that file, but you don’t want to change it so simply press enter.

  10. cheese kimbap says:

    can i have multiple virtual host in 1 conf file?


    DocumentRoot /mnt/d/example/public

    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted

    DocumentRoot /mnt/d/example/public

    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted

    I currently getting a
    “Not found URL {/some route} on this server

    Apache/2.4.29 (Ubuntu) Server at Port 80”

  11. md says:


    Thank you so much for this tutorial.

    I have followed everything, even edited my system32 host file, but I can’t seem to display any of the virtual host files.

    Any suggestion of what went wrong?


  12. Asaf says:

    Please note that step 6 (modifying host file) is done on the computer you’re browsing from (the web client), which isn’t always the same as the web server.

  13. Incrisz says:

    hey i followed the whole steps but my site is showing no server found …please what could have gone wrong?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.