


Now also you need to map the IP address to be the localhost. So in the example above a vhost for is created and the document root is in the Sites/apple folder, in the text block above I have also added in some log files, what you need to change is the document root location username and domain name to suit your needs. ServerAlias ErrorLog "/private/var/log/apache2/-error_log"ĬustomLog "/private/var/log/apache2/-access_log" common We can take this example and extend on it, if you wanted a domain named for example, you can copy the existing text block and edit to suit: sudo nano /etc/apache2/extra/nfĪn example domain in the file is given of the format required to add in additional domains, just follow this to create your new virtual host: ĭocumentRoot "/usr/docs/" Open this file to add in the virtual host. Include /private/etc/apache2/extra/nf Edit the nf file Search for ‘ vhosts‘ and uncomment the include line # Virtual hosts Allow the vhosts configuration from the Apache configuration file nf

The process of setting up Virtual Hosts is done easier in the Terminal either using nano or vi with sudo or as a root user, or you can you a GUI visual editor like BBEdit which allows access to the /private/etc directory by clicking ‘Show Everything” in the open dialog box.

This guide will also work in macOS Catalina, Mojave, High Sierra and Sierra. Setting up Virtual Hosts in Apache on on macOS Big Sur is straight forward after you have your local Web Development environment up and running – get your web development up and running first including Apache, PHP and MySQL on macOS following this macOS Big Sur Apache/PHP/MySQL guide here if required.
