How to Create An Apache 2 Virtual Host on Debian 10 Buster Easy Guide

July 21, 2019 | By the+gnu+linux+evangelist.

Setting Up

  1. 2. Editing Hosts

    Add the Domain to the hosts Config File.

    sudo nano /etc/hosts

    If Got “User is Not in Sudoers file” then see: How to Enable sudo
    Append:

    127.0.0.1 [myDomainName.com]

    Just Substitute your real Domain Name to “[myDomainName.com]” :)
    Ctrl+Shift+v to Paste Content on nano
    Ctrl+x to Save and Exit from nano Editor

  2. 3. Making VHost Folder

    Create the VHost Target Directory.

    sudo mkdir /var/www/html/[myDomainName.com]

    And may be also a Testing index.html:

    sudo su -c 'echo "My New WebSite is Working! :)" > /var/www/html/[mySite]/index.html'

    Then Set the Domain’s Ownership with:

    sudo chown -R www-data:www-data /var/www/html/[myDomainName.com]
  3. 4. Making VHost Config File

    Now Create a VHost Config File.

    sudo nano /etc/apache2/sites-available/[myDomainName].conf

    Append at Least:

    <VirtualHost *:80>
    ServerName[myDomainName.com]
    ServerAliaswww.[myDomainName.com]
    DocumentRoot /var/www/html/[myDomainName.com]
    </VirtualHost>
    

    Possibly substitute the actual Port to 80.
    To get a little More Insight may look:

    cat /etc/apache2/sites-available/000-default.conf
  4. 5. Enabling VHost

    Enabling the New Virtual-Host.

    cd /etc/apache2/sites-enabled
    sudo ln -s ../sites-available/[myDomainName].conf .

    Finally, Restart Apache2 Web Server

    sudo service apache2 restart
  5. How to Enable Apache2 mod_rewrite Module on Debian.

    Enabling Apache2 Rewrite for Debian

    How to Create a IP-based Virtual Host on Linux Debian

    How to Create an IP-Based Virtual Host on Debian.

    Debian Apache2 IP Virtual-Host

Contents


QuickChic Theme • Powered by WordPress