Host multiple websites on Apache in CentOS
This tutorial shows how to setup Apache Virtual Hosts in CentOS 7. This is useful if you want to host more than one website on a single CentOS web server. For instructions on how to setup Apache, PHP, and SQL database on CentOS 7, check this article.
Setup folder structure for your websites
We are going to create 2 folders for each website. The first will hold HTML and other content, second - log files.
/var/www/sites/domain1/html
/var/log/httpd/domain1
/var/www/sites/domain2/html
/var/log/httpd/domain2
/var/www/sites/domain3/html
/var/log/httpd/domain3
Log files will be stored in var/log/httpd/... subfolders, which is the default place to store log files in Linux. People often store Apache log files in /var/www/ subfolders, but in CentOS with SELinux enabled this can cause access denied errors. This can be fixed with chcon command, but I prefer to store all my log files in /var/logs...
You can also place index.html files with some sample text in each html directory which we'll use later for testing.