How to set up a local subdomain or domain


How to set up a local subdomain or domain

Posted on 30th Jan 2025

A quick guide or reference for configuring Apache web server to support a local domain or subdomain.

Linux Ubuntu Local Subdomain Setup Example.

To set up a local subdomain on Ubuntu server / desktop with Apache2, follow these steps:

  1. Edit the /etc/hosts file: Add the subdomain to the /etc/hosts file by running the following command:

    sudo nano /etc/hosts
    

    Add the following lines at the end of the file:

    127.0.0.1   autonetix.yourdomain.local
    

    Replace autonetix with your desired subdomain name and yourdomain.local with your local domain name.

  2. Create a new Apache virtual host:

  3. Create a new directory to store your web files in:
    sudo mkdir /var/www/autonetix.yourdomain.local
    
  4. Create a new file in the /etc/apache2/sites-available directory:
    sudo nano /etc/apache2/sites-available/autonetix.yourdomain.local.conf
    
  5. Add the following configuration:
    <VirtualHost *:80>
      ServerAdmin [your_email@example.com](mailto:your_email@example.com)
      ServerName autonetix.yourdomain.local
      DocumentRoot /var/www/autonetix.yourdomain.local
    VirtualHost>
    
  6. Replace your_email@example.com with your email address and /var/www/autonetix.yourdomain.local with the directory containing your subdomain's files.

  7. Enable the new virtual host: Enable the new configuration by running:

    sudo a2ensite autonetix.yourdomain.local
    
  8. Restart Apache: Restart Apache to apply the changes:
    sudo service apache2 restart
    
  9. Verify the setup: Open a web browser and navigate to http://autonetix.yourdomain.local. If everything is set up correctly, you should see your subdomain's files.

Remember to replace yourdomain.local with your actual local domain name and autonetix with your desired subdomain name throughout the process.

Uploaded files
    No files found for this post.

copyright © 2025 Autonetix.co | Autonetix.au