Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Help running multiple websites

I have installed Mountain Lion Server and would like to use it to host multiple websites on one Mac, but it is not immediately obvious to me how to do it. I can see how to add sites and the fact that it creates additional folders in /Library/Server/Web/Data/Sites but I can't work out how to access these, either internally or externally. According to something I read I should be able to access a site locally as, say, localhost/Default but even though localhost gives me the website in Default, the localhost/Default URL comes back invalid. Likewise, even if it worked locally, I then don't see how I would access the different sites externally - what is the mechanism that would cause the server to select the correct folder ? None of this basic stuff seems to be documented anywhere that I can see.


Tony

Mac mini (Mid 2011), OS X Mountain Lion

Posted on Aug 20, 2012 8:49 AM

Reply
24 replies

Aug 20, 2012 3:22 PM in response to tonydenson

The external reachablity:

First add the websites in Server (the program) then use a DNS service (like GoDaddy or name.com) to host your domain name and point an a-record to the public ip address of your server (the internet protocol address assigned to your modem). If the server is running inside your home, please make sure you configure your modem to forward port 80 for http and port 443 (https) to your internal ip address.


The internal reachability:

For using a web server in conjunction with domain names inside your home you'll need a DNS server. You're in luck, because OS X Server comes with one! The only thing that a DNS server does by the way is handing out ip's based upon the requested domain name and you need to tell your client computer where to ask for the ip address.


Read more:

http://help.apple.com/advancedserveradmin/mac/10.8/#apd1AB74EDF-C5B3-4C20-AD02-4 2120FF3B208

Aug 21, 2012 5:10 AM in response to tonydenson

Let's say you set up a website TonyDenson.com and run it on your home Mac. First thing to do is edit your "hosts" file located at /private/etc/hosts and add lines like this:

127.0.0.1 TonyDenson.com

This tells the browser the requested website is at your own machine 127.0.0.1. You can do this with as many websites as you want.


For internet access to your website, you need to set a custom DNS at your domain registrar. However be aware that running internet-facing websites in your home can severely degrade your internet speed. Gradually over time searchbots find your site and index all your stuff while hogging your upstream bandwidth because the server is sending a lot of stuff. Some sort of robot control is essential for home servers, unless you have 30 megabit fiber.

Aug 21, 2012 6:03 AM in response to Gnarlodious

Gnarlodious wrote:


Let's say you set up a website TonyDenson.com and run it on your home Mac. First thing to do is edit your "hosts" file located at /private/etc/hosts and add lines like this:

127.0.0.1 TonyDenson.com

This tells the browser the requested website is at your own machine 127.0.0.1. You can do this with as many websites as you want.


For internet access to your website, you need to set a custom DNS at your domain registrar. However be aware that running internet-facing websites in your home can severely degrade your internet speed. Gradually over time searchbots find your site and index all your stuff while hogging your upstream bandwidth because the server is sending a lot of stuff. Some sort of robot control is essential for home servers, unless you have 30 megabit fiber.


It isn't that I actually want to run the websites internally. I just want to be able to test my set up without going via the internet.

I'm still not sure I understand the external access. Is it simply the fact that I point my specific domain at my webserver machine that then causes the redirection to happen to the appropriate folder because I can't seem to get that to work. I always get the website that's in the Sites/Default folder.

Aug 21, 2012 6:06 PM in response to tonydenson

If all you want is a devbox running Server.app, set up a local domain like TonyDenson.dev in the GUI. In "Websites", click the + button below and add your info. Navigate using "Store files in" to the folder holding your pages and make sure a default page is in that folder, unless "folder listing" is enabled in Advanced. You should be ble to get your page with the URL TonyDenson.dev in the URL bar. But like I explained previously, it needs to be set up in the hosts file since it acts like a simple DNS redirector to your own machine. Every site you set up has a "View server website" button at the bottom that will open that website in the browser.


I don't understand what you are asking about internet so I'll ignore that for now, it sounds like you don't really want an internet facing server. Notice that Server.app does not support the Sites folder like the built-in Apache setup, which incidentally is still there and perfectly usable. In many ways it was simpler for a devbox setup, as Server.app is optimized as a dedicated server with multiple services running. You should also get used to Console.app to view your Apache error.log and system messages for some sort of Apache troubleshooting.


EDIT:

I take that back about the "View server Website" button, apparently it is broken as of this recent Server.app update. In my case, it takes me to gnarlodious.local instead of gnarlodious.dev. it seems to be a bug.


Message was edited by: Gnarlodious

Aug 22, 2012 1:43 AM in response to Gnarlodious

Gnarlodious wrote:




I don't understand what you are asking about internet so I'll ignore that for now, it sounds like you don't really want an internet facing server. Notice that Server.app does not support


I have obviously not explained myself very well. I absolutely DO want an internet facing server. the internal stuff is a red herring. I only asked about it because I just assumed there would be a trivial way of checking that each Sites folder contains what I think it contains when I am having trouble accessing externally. I can just as easily navigate to the folders with Finder.


In the absence of any Apple documentation on the subject (as far as I can see anyway) can I describe how I think it works and someone correct me if I am wrong -



I have a domain www.thepetstopshop.co.uk and I have set web forwarding on that to redirect it to the external ip address of where my server machine is.

In my /Library/Server/Web/Data/Sites folder I have two subfolders - Default, and PetStop (Default is the one created by the installation of Server.app). PetStop contains the website for thepetstopshop.co.uk. (obviously I have set up my router to point HTTP requests to the machine in question).

My understanding is that if I access thepetstopshop.co.uk from a browser on an external machine then Server.app somehow will know to serve up the contents of the PetStop folder, but if I were to access the server purely by its actual ip address then I would get the contents of Default.

Aug 22, 2012 2:00 AM in response to tonydenson

Have you set up your modem to forward incoming requests to your router? If not, you should definitely.


What did you do to the CustomSites folder? Hosting just based on virtual names is very common to host multiple domains on a single machine. What happens is that the browser always sends a request for your website containing the host name and that way the server know what website to spit out.


If you want your ip based access to hand out the content of www.thepetstopshop.co.uk as well and only host that site on your server, please move your website to the Default folder and remove the thepetstopshop.co.uk site in Server.app's Websites section, if only it were for not having to update 2 directories when making changes to your website.


When you would have multiple IP addresses configured to your server (in network preferences you can just duplicate your web-facing interface and apply another IP to the copied interface), you can set different ip's to different websites as well.

Aug 22, 2012 2:00 AM in response to tonydenson

Just to follow up on my previous message about how I think it works, I ought to explain what is actually happening.


As it happens I have a third folder in Sites called www.dens0n.com which is another of my domains. It doesn't matter how I access my server I always get the contents of that served up. i.e. whether I address it externally as the ip address, www.thepetstopshop.co.uk or dens0n.com.

Aug 22, 2012 2:07 AM in response to Mark23

Mark23 wrote:



What did you do to the CustomSites folder? Hosting just based on virtual names is very common to host multiple domains on a single machine. What happens is that the browser always sends a request for your website containing the host name and that way the server know what website to spit out.


If you want your ip based access to hand out the content of www.thepetstopshop.co.uk as well and only host that site on your server, please move your website to the Default folder and remove the thepetstopshop.co.uk site in Server.app's Websites section, if only it were for not having to update 2 directories when making changes to your website.



What is this CustomSites - I have never heard of it ?


I read somewhere that it's not a good idea to change the Default folder as it can produce spurious side effects. Anyway, I have multiple sites so I will need additional folders anyway.

Aug 22, 2012 2:23 AM in response to tonydenson

The /Library/Server/Web/Data/Sites/CustomSitesDefault folder is installed when you install Server with the owner root and group wheel.


I've never heard of these side effect by the way?


Just let server.app make the folders and you should be fine.


Why is the name www.thepetstopshop.co.uk opened showing the ip 82.7.140.46 instead of www.thepetstopshop.co.uk?


There has to be some kind of manual redirect either at your DNS provider or done manually at your server.

Aug 22, 2012 4:56 AM in response to Mark23

Mark23 wrote:


The /Library/Server/Web/Data/Sites/CustomSitesDefault folder is installed when you install Server with the owner root and group wheel.


Why is the name www.thepetstopshop.co.uk opened showing the ip 82.7.140.46 instead of www.thepetstopshop.co.uk?


On my system it installed /Library/Server/Web/Data/Sites/Default.


82.7.140.46 is the external ip address where the server is located, but just noticed I haven't set up the A records for the site. Have now done so, but will take some time to propagate.

Aug 22, 2012 9:16 AM in response to tonydenson

I have now set up yet another server on a totally different machine at a totally different location and am getting exactly the same behaviour i.e. however I access the webserver from an external browser it takes me to the website that is in Sites/Default. Can anyone please confirm that my earlier explanation of how I think it is meant to work is correct. Or at least point me to some Apple documentation that explains how to use this "easy to use" server software 😕

Aug 22, 2012 4:53 PM in response to tonydenson

If you ask for that domain on your own machine you must have the hosts file configured as I explained earlier. Have you looked at the log files? Do they say anything interesting? Any particular reason you are asking for the www subdomain? What happens if you ask for thepetstopshop.co.uk without the www. part? The reason is, you may not have told the domain to pretend to be the www subdomain. Look at the "Additional domains" option and make sure www.thepetstopshop.co.uk is added to the list of domain aliases. If it is not then no such domain www.thepetstopshop.co.uk exists and so your machine would serve up the default page. All this fun activity can be seen in the log file error.log and access.log


If thepetstopshop.co.uk is a new website I urge you to drop the www entirely and never publicize it as having that subdomain. Your URL will be shorter and more professional. The www subdomain was popularized by Microsoft when in reality there is no such standard as "www". If and when search engines get ahold of a www subdomain then that is where they send people. Best to kill it now before word gets out.


If you already have been running the www subdomain it is easy enough to redirect requests to thepetstopshop.co.uk so they will stop asking for www.thepetstopshop.co.uk.


-- http://Gnarlodious.com (no www!)

Aug 22, 2012 9:26 PM in response to tonydenson

On my OS X server, I run 3 domains and within that 6 separate websites - www.mydomain.com for wiki, www.mydomain.com.au for my company website ( drupal cms), crm.mydomain.com.au (sugarcrm CE) , webmail.mydomain.com for roundcube, and www.anotherdomain.com.au for another commercial site within my business.

In addition - I have a www2.mydomain.com.au for my dev system for the drupal site.


Simple Steps in Server.app By the way see the doco at


https://help.apple.com/advancedserveradmin/mac/10.8/ for Mountail Lion OS X server Advanced Admin.


1. set the internet host name

2. set DNS records

3. Add the web sites

4. add the info at your Domain Management Service

5. Optional add mail virtual domains as well.



The way to do it in Server.app is the following.


1. pick the domain name for your server that you wish to use and Edit the Host Name in Server.app - Select your Server in the Left Window, Select Network in the right and click edit host name and then make sure you tick hostname for internet on the way through. - if computer name is Server, then hostname should be server.dens0n.com for example. Don't worry about the commercial domain names as yet.


2. Start setting up DNS locally in Server.app

Select DNS from the list of services, and turn on.


Don't forget to add the address of your router as the forwarding domain server.



From memory, your primary zone should be set up , but if not, add a new record for the primary zone - dens0n.com


Add a machine record - Domain dens0n.com, Host Name "server" and ip Address - your internal ethernet address for your server (assuming its plugged into network via a router.


If planning to host mail

Add an MX record - Zone: dens0n.com , Mail Server "server.dens0n.com" Priority - 5 / 10 - whatever if its your only one.


Add a Nameserver record for the Zone dens0n.com - Nameserver "server.dens0n.com"


Add an Alias record to the Zone dens0n.com - Host name "www" - Destination "dens0n.com"


OK, that concludes setting up dens0n.com as your main domain.


2.a . Now, still in DNS, lets add a primary zone record for "thepetshop.co.uk"


Then add a Machine Record for that Zone


Zone : "thepetshop.co.uk"

Host Name "thepetshop.co.uk"

IP Address: For now - go with the same ip address as your main ethernet address on your server - i.e. the same ip address as you used for dens0n.com.


2b. If you are going to host mail for thepetshop.co.uk - go ahead and add an MX record


Zone: "thepetshop.co.uk"

Mail Server "server.dens0n.com"


2c. Add a www alias + a testweb alias ( just for example purpose)


Zone : thepetshop.co.uk

Host Name "www"

Destination "thepetshop.co.uk"


Zone : thepetshop.co.uk

Host Name "testweb"

Destination "thepetshop.co.uk"


Ok - so now we have set up two primary zones (dens0n.com and thepetshop.co.uk), weve added a name server rec, two MX records, and 3 alias records.


3. Web Sites.


Just a note. If you are going to use wiki - then it will take over the "Default web site".

The server will automatically set up a default Web Site on port 80 and a default SSL site on port 443 for whatever the hostname is. - so externally typing www.dens0n.com or server.dens0n.com will take you to the default web site.



To add your other websites in server.app (www.thepetshop.co.uk and testweb.thepetshop.co.uk) do the following


3. a Add a record - Click +


Domain Name - enter "thepetshop.co.uk" without the ""'s


Note - if you have set up dns correctly on your server, the little light will go Green - if it stays red, you have a problem.


IP Address - choose any and port 80

SSL None


Store Site Files In : - Choice here is automatically create folder - or navigate to one - I choose auto setup normally, and it creates a folder the same as the domain name entered in /Your path to Server/Web/Data/Sites


Whio can access - Anyone


Additional Domains - Edit and add a new record - www.thepetshop.co.uk

Edit Advanced Settings as required.


3. b - Go ahead and add a new website for testweb.thepetshop.co.uk.



3.c. To get your local machines to access the different web sites, you will need to change their DNS server to be the tcp / ip address of your server. Hopefully, youve added the forwarding server to the DNS setup so anything not serverd by your server - goes to the router and out to the internet.



Step 4. Set up yoour DNS Management Service Nameservers.


Youll need to add your A records and your MX records for your domains and point them to your external ip.


You should all be set.




Cheers

Gerry

Aug 23, 2012 12:59 AM in response to Gnarlodious

Gnarlodious wrote:


If you ask for that domain on your own machine you must have the hosts file configured as I explained earlier. Have you looked at the log files? Do they say anything interesting? Any particular reason you are asking for the www subdomain? What happens if you ask for thepetstopshop.co.uk without the www. part? The reason is, you may not have told the domain to pretend to be the www subdomain. Look at the "Additional domains" option and make sure www.thepetstopshop.co.uk is added to the list of domain aliases. If it is not then no such domain www.thepetstopshop.co.uk exists and so your machine would serve up the default page. All this fun activity can be seen in the log file error.log and access.log


If thepetstopshop.co.uk is a new website I urge you to drop the www entirely and never publicize it as having that subdomain. Your URL will be shorter and more professional. The www subdomain was popularized by Microsoft when in reality there is no such standard as "www". If and when search engines get ahold of a www subdomain then that is where they send people. Best to kill it now before word gets out.


If you already have been running the www subdomain it is easy enough to redirect requests to thepetstopshop.co.uk so they will stop asking for www.thepetstopshop.co.uk.


-- http://Gnarlodious.com (no www!)

I am well aware of the www issue and often poin out to friends that in the vast majority of cases it is not necessary, and indeed am irritated by sites that require it. Having said that the average man in the street believes it to be neceesary and that is why I make it available.

Aug 23, 2012 1:31 AM in response to redshift82r

redshift82r wrote:



Simple Steps in Server.app By the way see the doco at


https://help.apple.com/advancedserveradmin/mac/10.8/ for Mountail Lion OS X server Advanced Admin.



I did look at that previously, but it doesn't answer my basic question above about how does the fact that the user typed a certain website name get translated into which folder gets served. By inference though I have now assumed that my expalnation ealrier is correct even though noone has confirmed it for me explicitly.

Help running multiple websites

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.