Mac configures multiple virtual hosts for the Apache2 server when we do the project sometimes need to operate multiple projects at the same time, but the Apache server defaults only provide a root directory, this time is more troublesome, we can configure multiple virtual host to achieve this problem
1. Edit the apache2 configuration file sudo vim/etc/apache2/httpd.conf and then cancel the comment line so that the virtual host is enabled.
2. Edit sudo vim/etc/apache2/extra/ httpd-vhosts.conf configuration of the virtual host directory you want, it is recommended to set the virtual directory in the same directory, because the next to configure the directory permissions, if not configured in the same directory, each configuration directory to set permissions to access the more troublesome.
3. Do not forget to open the set host address permissions, or error forbidden errors, so to open the directory in httpd-vhosts.conf or http.conf file access permissions, the system default address is/library/ webserver/documents/, all I have is to configure all the directories to/library/webserver/, so as long as the permissions to open the/library/webserver/directory is OK.
4. The final step, but also the most important step, is to add the 127.0.0.1 hostname in the vhosts file, which is configured to point to the host address you configured 127.0.0.1 (native address), sudo vim/etc/hosts.
sudo apachectl-k start start
sudo apachectl-k stop stop
sudo apachectl-k restart restart
Mac configures multiple virtual hosts for APACHE2 servers