How to Create sub domains on localhost in apache on Ubuntu

When working with apache locally, the common way to use it is though the “localhost” url. When doing web development or some kind of testing, you might need to create sub domains on localhost, just like on online servers. This post shows you how to create sub domains inside Apache on localhost.