www.mrdevtools.com

How to set up hosts on local machine (Ubuntu)

This post is about how can set up hosts on local machine. Your hosts will take hostnames as:

  • xxx.local
  • site1.local
  • site2.local
  • site3.local

I use an Apache2 server running on Ubunto 18.04. To enable and disable local hostings, the commands a2ensite and a2dissite are respectively used as enable and disable.

For each new local host, I use a file mal.conf which on my machine is sitting in the folder:
/etc/apache2/sites-available

Replace the "xxx" with your site name. and this is how the mal looks like:

Summary

steps to remember:
  • make a xxx.conf file edit and enable the site
  • make a DocumentRoot-folder which the new site points to
  • create a default index.php in DocumentRoot
  • change owner and public right access to the folder
  • add new host to the local hosts-file
  • check the new site is responding and serving the index-page