Web Hosting With OS X (Mountain Lion and Later)

How to Regain Control of Web Sharing in OS X Mountain Lion and Later

OS X Server (OS X Yosemite)
Courtesy of Apple

Starting with OS X Mountain Lion, and continuing with all subsequent versions of OS X, Apple removed the Web Sharing feature that made sharing a web site or related services a simple point-and-click operation.

The Web Sharing feature uses the Apache web server application to allow you to run your own web server on your Mac. Many individuals use this capability to host a local web site, web calendar, wiki, blog, or other service.

Some businesses use Web Sharing to host workgroup collaboration features. And many web developers use Web Sharing to test their site designs before moving them to a production web server.

The modern OS X client, that is, OS X Mountain Lion and later, no longer provides controls for setting up, using, or disabling Web Sharing. The Apache web server is still included with the OS, but you can no longer access it from the Mac's user interface. You can, if you wish, use a code editor to manually edit the Apache configuration files, and then use the Terminal application to start and stop Apache, but for a feature that was click-and-go easy in previous versions of the OS, this is a big step backwards.

If you need Web Sharing, Apple recommends installing the Server version of OS X, available from the Mac App Store for a very reasonable $19.99. OS X Server provides much greater access to the Apache web server and its capabilities than was ever available with Web Sharing.

But Apple made a huge mistake with Mountain Lion. When you perform an upgrade install, all of your Web Server settings remain in place. This means your Mac can run a web server, but you don't have an easy way to turn it on or off.

Well, that's not entirely true. You can turn the web server on or off with a simple Terminal command, which I include in this guide.

But Apple should have provided an easier way to do this, or better yet, continued supporting Web Sharing. Walking away from the feature without providing an off switch is beyond belief.

How to Stop the Apache Web Server With a Terminal Command

This is the quick-and-dirty way to stop the Apache web server used in Web Sharing. I say "quick and dirty" because all this command does is turn the web server off; all of your web site files remain in place. But if you just need to shut down a site that was migrated to OS X Mountain Lion or later and left running, this will do it.

  1. Launch Terminal, located at /Applications/Utilities.
  2. The Terminal application will open and display a window with a command line.
  3. Type or copy/paste the following text at the command prompt, and then press return or enter.
    sudo apachectl stop
  4. When requested, enter your administrator password and press return or enter.

That's it for the quick-and-dirty method for stopping the Web Sharing service.

How to Continue Hosting a Web Site on Your Mac

If you want to continue using Web Sharing, Tyler Hall offers a very handy (and free) system preference pane that lets you start and stop Web Sharing from the more familiar System Preferences interface.

After you download the Web Sharing preference pane, double-click the Web Sharing.prefPane file and it will be installed in your System Preferences. When the installation is complete, launch System Preferences, select the Web Sharing preference pane, and use the slider to turn the web server on or off.

Gain More Web Sharing Control

Tyler Hall created another handy app, called VirtualHostX, which provides much more control over the Mac's built-in Apache web server. VirtualHostX lets you set up virtual hosts or set up a complete web development environment, just the thing if you're new to web design, or if you want a quick and easy way to set up a site for testing.

While it's possible to host web sites from your Mac using Web Sharing and VirtualHostX, there are two additional development and hosting systems that deserve a mention.

MAMP, an acronym for Macintosh, Apache, MySQL, and PHP, has long been used for hosting and developing web sites on the Mac. There's an app with the same name that will install Apache, MySQL, and PHP on your Mac. MAMP creates an entire development and hosting environment that is separate from the utilities Apple provides. This means you won't have to worry about Apple updating the OS and causing a component of your web server to stop working.

OS X Server currently provides all of the web serving capabilities you will probably need in one easy-to-use package. Besides web serving, you also get File Sharing, Wiki Server, Mail Server, Calendar Server, Contacts Server, Messages Server, and much more. For $19.99, it's a good deal, but it requires careful reading of the documentation to properly set up and use the various services.

OS X Server runs on top of your current version of OS X. Unlike earlier versions of the server software, OS X Server isn't a complete operating system; it requires that you've already installed a current version of OS X. What OS X Server does is provide an easy way to manage server operations that are actually already included in the standard OS X client, but are hidden away and disabled.

The advantage of OS X Server is that it's a great deal easier to use to manage the various server operations than trying to do so using code editors and Terminal commands.

Apple dropped the ball when it eliminated the Web Sharing feature that's been part of OS X since it was first released, but fortunately, there are other options available if you want to continue using your Mac for web hosting and development.

Publish: 8/8/2012

Updated: 1/14/2016