

Just make sure you change the "8888" port to whatever port you're using on your system. If you're trying to configure an Apache NameVirtualHost on your system, if you'll just copy the second configuration entry I'm showing above and start with that, you should be fine.
MACOS SERVER VIRTUAL HOSTS MAC OS X
Mac OS X /etc/hosts entriesĪlong with this configuration file, I have these corresponding entries in my Mac /etc/hosts file: However, because I am currently developing PHP applications, I need those Directory entries.

If you’re not using PHP you can trim these entries down even more, as shown next: In short, as I’m developing two different applications, one named "cato" and another named "zenf", these are the important name-based virtual host lines from my Apache configuration file:ĭocumentRoot /Applications/MAMP/htdocs/catoĭocumentRoot /Applications/MAMP/htdocs/zenf In particular, this is from the nf configuration file that I use with MAMP on one of my Mac OS X development systems.
MACOS SERVER VIRTUAL HOSTS HOW TO
Tested using XAMPP 1.7.2a for Mac and Snow Leopard 10.6.Summary: Here are some notes on how to configure a Name Virtual Host (NameVirtualHost) on an Apache web server. Execute the following command in your terminal. To do this, we need to modify the nf file.

Check here for ways to assign a computer a static IP address. Enabling virtual hosts on Mac OS X The first step to making this work is enabling virtual hosts on Mac OS X. Īs the iMac’s IP address is hard-coded in the MacBook’s /etc/hosts file it’s important to ensure that the iMac is always assigned the same IP address on the network. This way, when it’s connected I can point my browser to and when not connected I can use. I can of course delete macbook.mysite1 now if I wish, but I find it’s convenient to keep both, particularly as the MacBook may not always be connected to my network. NGINX does not have Virtual hosts, it has Server Blocks that use the servername and listen directives to bind to. If not, I’ll be unable to access the virtual host and it will default to localhost on the iMac. The only difference from the previous example is that the name ( imac.mysite1) must be the same as that configured on the iMac. The IP address of the iMac on my network is 192.168.1.10, so to access the default localhost on the iMac from the MacBook I simply add the following to the MacBook’s /etc/hosts file: For now we’re only interested in the default localhost. The /etc/hosts file on the MacBook is almost identical apart from the virtual hosts entry which is: # localhost is used to configure the loopback interface The /etc/hosts file on the iMac looks like this: Virtual Hosts 127.0.0.1 macbook.mysite1 Network Hosts 192.168.1.10 imac.localhost 192.168.1.10 imac.mysite1 The only difference from the previous example is that the name ( imac.mysite1) must be the same as that configured on the iMac. I have an iMac and a MacBook both of which have local server environments. However, it is possible to have any computer on a local network serve pages that are stored on another computer on that same network. No big deal really as I currently use ChronoSync to synchronise my site’s folder structure across computers. Code: Select all Expand view Collapse view NetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter IP: 192.168.56.100 NetworkMask: 255.255.255.0 lowerIPAddress: 192.168.56. Virtualbox is 6.0.8 version with last extension pack installed. This means that if I have a local site on computer A that I wish to access on computer B I have to replicate that site’s entire folder structure on computer B and on all other computers I want to access the site from. I got 3 DHCP servers, 2 of which (host-only) are enabled but not running. As it stands, the local server on each computer can only serve pages stored on that machine. I have several computers on my local network each with a local server environment provided by XAMPP.
