Use Your Mac to Share a Web Site

Enable web sharing on your Mac

Your Mac comes equipped with the same Apache web server software that has made its reputation by serving up commercial websites. Configuring an Apache web server isn't for the faint of heart, but for a long time, OS X included an easy-to-use interface to the Apache web server that allowed just about anyone to serve up a website with a series of simple mouse clicks.

The basic web sharing service remained part of OS X until the release of OS X Mountain Lion, which removed the simplified user interface but left the Apache web server installed. Even today, OS X ships with an up-to-date version of the Apache web server, ready for anyone to use, just not with a simplified user interface.

Create Your Website in OS X Lion and Earlier

Web sharing options in OS X

Providing detailed instructions for creating a website is beyond the scope of this guide. But for this tip to be of any use to you, you'll eventually need to create your own website, which is something you probably want to do anyway.

Personal Web Sharing

Your Mac supports two locations for serving up a website from; the first is for personal websites created by each user on your Mac. This is an easy way for every member of a family to have their own website.

Personal websites are served up by the same Apache web server that handles commercial websites, but they're stored within the user's home folder, specifically, in the Site directory, which is located at ~/username/Site.

Don’t go looking for the Site directory just yet; OS X doesn’t bother to create the Site directory until it's needed. We'll show you how to generate the Site directory in a moment.

Computer Website

The other location for serving up a website goes by the name computer website. This is a bit of a misnomer; the name actually refers to the main Apache documents folder, which contains the data for websites that the web server will serve up.

The Apache documents folder is a special system-level folder, which is restricted to administrators by default. The Apache documents folder is located at /Library/WebServer. The documents folder's restricted access is the reason why OS X has personal Site folders for each user, which, as you might guess, allows users to create, manage, and control their own sites without interfering with anyone else’s.

If your intent is to create a company website, you may want to use the computer website location, as it will prevent others from being able to easily make changes to the website.

Creating Web Pages

Use your favorite HTML editor or one of the popular WYSIWYG web page editors to create your site. You should store the website you create in your user Site directory or the Apache Documents directory. The Apache web server running on your Mac is configured to serve up the file in the Site or Documents directory with the name index.html.

Enable Web Sharing in OS X Lion and Earlier

  1. Click the System Preferences icon in the Dock.

  2. Click the Sharing icon in the Internet & Network section of the System Preferences window.

  3. Place a check mark in the Web Sharing box. (OS X 10.4 Tiger calls this box Personal Web Sharing.) Web sharing will turn on.

  4. In the Sharing window, click the Create Personal Sites folder button. If the Sites folder is already present (from earlier use of the web sharing preference pane), the button will read Open Personal Website Folder.

  5. If you wish to use the Apache documents folder to serve up a website, click the Open Computer Website Folder button.

That’s it; Apache web server will start up and serve at least two websites, one for the computer, and one for each user on the computer. To access any of these websites, open your favorite browser and enter any of the following:

  • This is the computer's web page. To find your computer's address, bring up the Sharing window you accessed above, and highlight the Web Sharing name in the list. Your computer's address will display to the right.
  • This is your personal web page. To access it, enter the computer's address from the previous step, followed by the ~ (tilde) character and your user shortname, with no spaces in the shortname or between the tilde and your shortname.

If you're not sure what your shortname is, bring up the Sharing window you accessed earlier, and highlight the Web Sharing name in the list. Your personal website address will display to the right.

Web Sharing OS X Mountain Lion and Later

With the introduction of OS X Mountain Lion, Apple removed Web Sharing as a feature. If you’re using OS X Mountain Lion or later, you'll find instructions for web sharing in the Web Hosting With Mountain Lion guide.

If you were already using Web Sharing to serve up web pages from previous versions of OS X, and have since updated to OS X Mountain Lion or later, be sure to read the Web Hosting with Mountain Lion guide linked above. With the removal of the web-sharing interface, you may find yourself in the unusual predicament of having a web server running with no obvious way to turn it off.

Using Mac OS Server to Host Web Sites

The limitations imposed by using the Mac's built-in Apache server is only present in the standard version of the Mac OS. Those limitations fall away once you make the move to Mac OS Server which offers a rich collection of server features, including mail server, web server, file sharing, Calendar and Contacts server, Wiki server, and much more.

Mac OS Server is available from the Mac app store for $19.99. Purchasing Mac OS Server will restore all of the web sharing services and quite a bit more to your Mac.