![]() ![]() ![]() # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # You may use the command line option '-S' to verify your virtual host # configuration. # Please see the documentation at # for further details before you try to setup virtual hosts. This is indicated by the asterisks in the directives below. Most configurations # use only name-based virtual hosts so the server doesn't need to worry about # IP addresses. Remove or comment out the virtual host entries and place your virtual hosts at the end of the file like so: # Virtual Hosts # Required modules: mod_log_config # If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHost containers for them. Now, type the following into Terminal to edit the virtual hosts: sudo nano -w /private/etc/apache2/extra/nf Now you will close and save the file: hit control x to exit, then type y, and hit return to save your changes. You can add more hosts on new lines by using the same format: 127.0.0.1 ariadoss.loc 127.0.0.1 hogwartslive.loc 127.0.0.1 authorwars.loc Hold control v until you reach the end of the file and place this text at the end, replacing ariadoss.loc with whatever name you’d like to use for your virtual host: 127.0.0.1 ariadoss.loc #BBEDIT FOR MAC 10.10 PASSWORD#When you put sudo in front of a command you will need to enter your administrator/user password if prompted to do so. Go to the Terminal window and type: sudo nano -w /etc/hosts Be careful not use something like as a name because web browsers will check your host file first and go to your local machine instead of the live website located at. Alternatively, you could use a subdomain like but some codebases won’t run properly on a subdomain. ![]() ![]() Instead, I will be using domains like so I remember I’m working on the local (hence the. com version of the domain names because I want those URLs to go to the live version of my website. Set up a Name-Based Virtual Host You will first need to select a name for your virtual host, in this case I want to create a virtual host to test my local copies of, , and but don’t want to use the. Alternatively, for you lazy ones out there, you can just copy and paste these commands. Whenever I ask you to type something into Terminal you have to hit the return key for the command to go through. I will be using the GNU nano text editor in my examples since it already comes with the Mac, but if you’d like to use BBEdit or TextMate just replace nano with bbedit or mate respectively and remove any nano-specific options (e.g. Open up the Terminal application in /Applications/Utilities or if you prefer use iTerm. #BBEDIT FOR MAC 10.10 HOW TO#What are virtual hosts used for? In the case of this tutorial we will create a virtual host to let us access a subfolder on our local web server at a custom address like or instead of having to type in a longer URL like Preparation This tutorial assumes you either followed my tutorial about How to set up Apache, PHP, & MySQL on Mac OS X 10.10 Yosemite or already have a similar setup and are somewhat familiar with what you’re doing. If you know what you’re doing this guide should also work for Leopard, Snow Leopard, Lion, Mountain Lion, and Mavericks with minor changes as the setup hasn’t changed much since I originally wrote about this in 2009. This tutorial is intended as a supplement to my article, How to setup Apache, PHP & MySQL on Mac OS X 10.10 Yosemite. This is a simple guide on how to set up name-based virtual hosts in Apache on Mac OS X 10.10 Yosemite. How to set up Virtual Hosts on Mac OS X El Capitan 10.11 El Capitan & Mac OS X 10.10 Yosemite ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |