Your Mac comes equipped with the same Apache web server software that made its reputation by serving up commercial websites. Anyone using OS X Lion (10.7) and earlier can set up web sharing on their Mac by using an easy-to-use interface to access the Apache web server.
This setup on OS X made it easy for 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.
Personal Web Sharing in OS X Lion and Earlier
Your Mac supports two locations for serving up a website. The first is for personal websites created by each user on your Mac. This separation offers an easy way for every member of a family to have a website.
Information in this article refers to Mac web sharing using OS X Lion (10.7) and earlier. Apple recommends purchasing OS X Server or macOS Server to return web sharing capabilities to users of OS X Mountain Lion (10.8) and later.
Find personal websites in the user’s home folder in the Sites directory, located at ~/username/Sites.
Don’t go looking for the Sites directory just yet. OS X doesn’t bother to create the Sites directory until it’s needed.
Computer Website in OS X Lion and Earlier
The other location for serving up a website goes by the name “computer website,” but this is a bit of a misnomer. The term refers to the main Apache documents folder, which contains the data for websites that the web server serves up.
The Apache documents folder is a 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 Sites folders for each user. Individual Sites folders allow users to create, manage, and control their own sites without interfering with anyone else’s.
If you intend to create a company website, you may want to use the computer website location, as it prevents others from making changes to the site easily.
Creating Web Pages in OS X Lion and Earlier
Use your favorite HTML editor or one of the popular WYSIWYG web page editors to create your site and store it in your user Sites directory or the Apache Documents directory. The Apache web server running on your Mac is configured to serve up the file in the Sites or Documents directory with the name index.html.
Enable Web Sharing
To enable web sharing in OS X Lion and earlier:
- Select System Preferences > Sharing.
- Place a check mark in the Web Sharing box to turn on web sharing.
- OS X 10.4 Tiger calls this box Personal Web Sharing.
- 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 reads Open Personal Website Folder.
- If you prefer to use the Apache documents folder to serve up a website, click the Open Computer Website Folder button.
Accessing Your Website
The Apache web server starts up and serves at least two websites, one for the computer and one for each user on the computer. To access any of these websites, open a browser and enter one of the following:
Select System Preferences > Sharing.
Place a check mark in the Web Sharing box to turn on web sharing.
OS X 10.4 Tiger calls this box Personal Web Sharing.
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 reads Open Personal Website Folder.
If you prefer to use the Apache documents folder to serve up a website, click the Open Computer Website Folder button.
- Use the format http://your.computer.address/ for the computer’s web page. To find your computer’s address, bring up the Sharing window and highlight the Web Sharing name in the list. Your computer’s address displays to the right.Use the format http://your.computer.address/~yourusername for a personal web page. To access it, enter the computer’s address from the previous step, followed by the ~ (tilde) character and your username with no spaces in the username or between the tilde and your username.
If you’re not sure what your username is, bring up the Sharing window you accessed earlier and highlight the Web Sharing name in the list. Your personal website address displays to the right.
OS X Server or macOS Server for Web Sharing
Newer Macs ship with an up-to-date version of the Apache web server that’s ready for anyone to use—just not with a simplified user interface. However, a move to OS X Server (or macOS Server depending on your operating system) returns web sharing capabilities to the Mac.
OS Server for OS X Mountain Lion and later offers a rich collection of server features, including mail server, web server, file sharing, Calendar and Contacts server, Wiki server, and more.
Get the Latest Tech News Delivered Every Day