The Sharing preference panel options were changed a bit in OS X Mountain Lion, and while things like Internet Sharing remain, the Web Sharing preference panel was removed. The Apache web server remains bundled with Mac OS X though, but you’ll need to turn to the command line to enable the web server. Additionally, you’ll want edit a user configuration file for each user account on the Mac to have the personal web sharing feature active. If any of this sounds intimidating or complex, it’s really not, just follow along and you’ll have a simple web server running on your Mac in no time.
Setting Up and Starting the Apache Web Server in OS X
Versions of OS X prior to Mountain Lion can simply turn on “Web Sharing”, but from 10.8 onward you’ll need to do the following to use a local web server:
- Launch Terminal, located in /Applications/Utilities/
- Type the following command, replacing USERNAME with the user account short name:
nano /etc/apache2/users/USERNAME.conf
- Enter the admin password when requested, then paste the following into the nano text editor:
<Directory "/Users/USERNAME/Sites/">
Options Indexes Multiviews
AllowOverride AuthConfig Limit
Order allow,deny
Allow from all
</Directory>
In the .conf file it will look like this:
- Edit the Directory path USERNAME to the appropriate username
- Now hit Control+O to save the changes to USERNAME.conf, then hit Control+X to quit out of nano
- Next, you will start the web server with the following command:
sudo apachectl start
- Launch Safari, Chrome, or Firefox and navigate to “http://127.0.0.1″ to verify the server is running, you will see an “It Works!” message