Home » Technology » Apple & Macs » ISP-In-A-Box: Hosting Multiple Web Sites And Domains On Your Mac

The Most Versatile VoIP Provider: FREE PORTING

ISP-In-A-Box: Hosting Multiple Web Sites And Domains On Your Mac

blankOnce you get a web site up and running on your Mac mini (or any other Mac running Mac OS X Panther or Tiger), you’ll probably get hooked and want to add additional web sites or domains. So today we’re going to give you a template that can be used to add additional sites to your heart’s content. In a previous article, we covered one approach to hosting multiple domains. In that scenario, we built separate web sites in the Sites folder for various user accounts on your Mac. Then using Omnis.com‘s DNS tools, we pointed different domains or subdomains to the appropriate web sites on your Mac using a Proxy (aka mod_proxy) record for the domain that looked like this (substituting your own IP address, of course):

  • Namewww
  • TypePROXY
  • Contenthttp://111.111.111.111/~johnny
  • That solution works; however, it forces you to log in as different users to manage the different web sites. Today’s approach assumes you want to manage multiple web sites from a single account on your Mac using the traditional web site folder heirarchy located at /Library/WebServer/Documents. Our site design for multiple web sites and multiple domains goes like this. We’ll create a websites folder below the /Library/WebServer/Documents folder. Then, for each new web site or domain, we’ll create a subfolder below the websites folder. We’ll leave the websites folder empty and adjust Apache to bar direct access to the contents of that folder. Then we’ll assign a TCP port for the new site and add the necessary code to support the new domain to the Apache config file, httpd.conf. Finally, we’ll point our domains to your Mac’s IP address using the proxy service of a domain registrar, restart Apache, and presto, you’ll be hosting multiple web sites from your Mac mini ISP-In-A-Box. One advantage of this design is that you still can remotely manage all of your web sites using a WebDAV client on almost any computer. We covered all of that here last week. We’re assuming you already have built your first web site using our Apache tutorials. If not, start here. Then go here and here. Then you’ll be ready to continue on with this tutorial. As with most of our articles, a degree in Rocket Science isn’t required, but you do have to use the Pico editor to make a few customizations to the Apache configuration files. For the Internet wizards reading this, you’re probably saying there’s an easier way to set up multiple web sites with Apache. Yes, there is. It just doesn’t seem to work in the Mac environment. If anyone comes up with a simpler method that works, do us all a favor and put it in a comment.

    Creating the First Web Site. Let’s begin by creating the folder that will house all of our new web sites. Open a Terminal window and switch to root access with your admin password: sudo su. Now move to the main web site folder: cd /Library/WebServer/Documents. Create the new websites folder: mkdir websites. Move to the websites folder: cd websites. Now create a directory to house our first new web site: mkdir mysite. For additional web sites, you’ll simply create additional folders below the websites folder as we just did.

    Modifying Apache to Support New Web Sites. Because of Apple’s configuration design, we’re going to configure our new web sites to use TCP ports in the eighties beginning with 81 rather than the default HTTP port, port 80. Remember not to use 82. We used that for our WebDAV server. So we’ll need to first edit httpd.conf in the /etc/httpd folder. Open a Terminal window and switch to root access: sudo su. Move to the Apache config directory: cd /etc/httpd. Make a duplicate of the httpd.conf file just in case something goes wrong: cp httpd.conf httpd.sav. Now carefully edit the Apache config file: pico httpd.conf. Switch back to your web browser and Ctrl-Click on the access.txt code snippet here and open it in a new tab or window in your web browser. Press Command-A then Command-C to copy the code snippet to your clipboard. Now switch back to your Terminal window and move to the bottom of the httpd.conf file by repeatedly pressing Ctrl-V. Copy the clipboard contents there by pressing Command-V.

    Now let’s look at what we pasted. The first three lines tell Apache not to display a directory listing of the websites folder if someone accesses your web site by typing: http://yourwebsite.com/websites/. The Listen 81 line tells Apache to listen on this TCP port as well as port 80. The VirtualHost _default_:81 line identifies the port which will be used to access this web site. The DocumentRoot and Directory lines tell Apache where the data for this web site is stored on your server: /Library/WebServer/Documents/websites/mysite. The allow from all line gives everyone access to this web site. And Options +Indexes tells Apache to display a directory listing of this folder if there is no index.html or index.php startup file in the folder. If you want to hide the directory if there is no startup file, change the plus sign to a minus sign.

    Now that you understand what the various lines in the config file do, let’s save the changes to httpd.conf: Ctrl-X,Y,enter. Now restart the Apache web server: apachectl restart.

    Firewall Adjustments. Remember to add a new port authorization in your Mac firewall to support port 81. Go to SystemPreferences->Sharing->Firewall and click the New button. Choose Other for the PortName, specify the desired TCP port number (81), and name the service HTTP81 so you can remember what it does. Click OK to save your update. Also make the necessary adjustment to your hardware based firewall to authorize the new port and point it to the internal IP address of your Mac. If your hardware firewall uses port 81 for remote access, be sure to change it to another port.

    Domain Registrar Adjustments. Finally, access your domain registrar’s web site (as previously noted, we recommend Omnis.com which supports proxy DNS entries) and, using the registrar’s DNS tools, add a proxy record to point your domain to the IP address and port 81 of your Mac web server: http://111.111.111.111:81 using your own IP address. You usually have to make two proxy record entries, one for @ and one for www if you want your web site accessible as either www.yourwebsite.com or yourwebsite.com. If you don’t know the IP address of your Mac web server, just access our IP site identifier using a web browser on your Mac web server, and it will tell you.

    Adding Additional Web Sites or Domains. When you’re ready to add additonal web sites or domains to your web server, just follow these simple steps. Add a new folder in the /Library/WebServer/Documents/websites folder. Add an additional Listen and VirtualHost block to your access.conf config file for each domain address which will be used to access the new web site. Be sure to change the access port to port 83 or higher and the web site directory location in every line that you added. Remember to use a different TCP port for each new domain you add. Restart your Apache web server. Make the necessary additions to your Mac and hardware-based firewalls to support the new port. Then add the proxy DNS entry for your new domain using your domain registrar’s proxy DNS tools. For a sample of what we just did using the mysite.webify.us subdomain, click here. Yes, we eat our own dog food.


    3 Comments

    1. Thank you so much for such an absorbing, understanding tutorial, but IT DID NOT WORK!!! I went through this a dozen times now, and now my prior website that was in the default /Documents folder does not load. Here is what I did:
      – I followed through the process to host multiple domains as above. (Keep in mind, I currently have [had] one in the default documents folder in the WebServer directory) so I created the new directory via terminal using my "vacouncil" in replacement of "mysite" for all instances. After restarting apache, I exited out of all terminal commands.
      – next, I added the port 81 to my firewall settings as you had illustrated.
      – next, I went into my router (netgear) and after refreshing everything, I added the range of ports from 80 to 81 and applied that.

      – and now, nothing loads. The new domain (www.vacouncil.org) and my existing domain (www.monroe-design.com) come up with instant "can’t connect to server" msgs. By now, I have tried restarting my Apache, my router (and unplugged), and my entire system to no avail.

      – I have registered previously my domains through register.com, whom I have been happy with and thought I may need to assign port #’s there, but there system won’t let me add " :80 " or " :81″ to the end of my IP. SO NOW that leads me to believe it is something with my router that I am looking past, or with the code that I copied above to enter into Terminal… ANY HELP WOULD BE SO GREATLY APPRECIATED… This tutorial was extremely helpful, but the long arm of Murphy’s law apparently got the best of me. (dan@monroe-design.com)

      [WM: Sorry you had a problem. Unfortunately, register.com doesn’t support mod-proxy DNS entries, i.e. those with a port address as well as an IP address. So your domain is being routed to port 80 on your Mac. If you transfer your domain to Omnis.com, all should be well.]

    2. Hello.

      I have been following the steps in this absorbing series and have an observation and question at this stage.

      OBSERVATION: The ISP in a Box can be followed on Tiger. While you mention several times that Panther should be used (I know it was mainly written pre Tiger) what I have done is open the Tiger Vittles upgrade page as well and applied the upgrades on the fly. It works.

      QUESTION. I will like to have another site in addition to the alpha stage one I now have but this section does not mention how this might work using something like DynDNS and just concentrates on Omnis. Is it the case that these type of services do not work? Although they give an extra "dot" in the name, I really like the fact that the update clients can automatically reset the IP address. Is there a way to use these services??

      Thanks

    3. Answer to my question. I just found out that DynDNS offers a free "WEBHOP" service that can redirect to a specific port. Throws up a popup on first entry nut there’s no free lunch! Good enough for me….At least for a start.

    Comments are closed.