If Apache has been your web server of choice for years, and you’re finally migrating to Apache2, it’s time to learn a new trick: setting up multiple virtual hosts with Apache2.
If you’re a Linux system administrator, chances are you’ve worked with Apache. And if you’ve done enough Apache configuration, you’ve most likely set up virtual hosts. But if you’re finally migrating away from your old Apache-powered web platform and onto Apache2 (the version of Apache shipped with the likes of Ubuntu Server), you’ll need to change your way of thinking.
I’ll walk you through the process of hosting multiple websites (aka virtual hosts) on an Apache2-based system (in this case Ubuntu 16.04). Believe it or not, it’s simple…you just have to know what to configure and where to configure it.
I assume you already have Apache installed and, if you point your browser to the server IP (or domain), either the Apache2 welcome page or your company site will appear. Let’s add yet another site to your Apache2 server.
With Apache2, all virtual hosts are configured in individual files with /etc/apache2/sites-available. Each file will end in .conf and contain all of the details for the host. An example .conf file will look like: