There would be a need for this or that reason to serve more than one site from apache. And this is quite possible using configuration inside the apache
First thing first
go to the apache config, by default it should be
And search for
Which, as you can see, is commented. Hence uncomment that by deleting the # infront of it.
The above task will allow us to mess around the httpd-vhosts.conf file that is in the extras directory.
Lets assume we have a site names siteVH which is residing in the directory /www/sitevh
and lets assume we have another site called siteAnother residing in director /www/siteanother
Now the goal is to access those sites independently. So we will create two different virtual hosts for each one and be able to access them independently
ServerAdmin firstname.lastname@example.org DocumentRoot "/www/siteVH" ServerName sitevh.com ServerAlias local.site ErrorLog "/private/var/log/apache2/sitevh.log" CustomLog "/private/var/log/apache2/sitevh.com-access_log" common AllowOverride All Order allow,deny Allow from all Options Indexes FollowSymLinks
And the we will have the same duplicate values for the other one as well.
Then update the /etc/hosts to let know our local “DNS” to know what to do
127.0.0.1 sitevh.com siteanother.com
This shall take care of the whole thing.
One more thing, restart apache
sudo apachectl restart