Tuesday, March 19, 2024
spot_img

Start and Stop OS X web server

OS X has a built in web server. For some users, especially web developers, it may come in rather handy. You can use it for locally hosting web sites (typically for development purposes), for running a local WebDAV server (which may, for instance, come in handy for local syncing of apps like OmniFocus).

When OS X 10.8 was released, Apple had removed the convenient “Web sharing” switch in the Sharing options of System Preferences. Here’s a couple of ways to start and stop you local Apache server:

1. With a GUI

There is a free Preference Panel available at Click On Tyler. One installed (takes a quick double-click)  you will have a new panel in your System Preferences which provides some very basic info about your Local Apache sites, and an easy way to turn the Apache server ON and OFF.

Web Sharing OS X

There is another Preference Pane here at Stowlake.com, although it says it works on 10.8 but nothing about 10.9 and above. It worth trying out though, if you want to give the GUI option a go.

2. Using Terminal commands

Personally, I recommend this method if you are getting into working with your system beyond the superficial (yet convenient) bling of the OS X GUI interface. Also, if you’re into developing web sites, becoming familiar with Apache commends on OS X is bound to come in handy over time.

To start the Apache server on OS X

sudo apachectl start

or

sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

(drop the -w if you don’t want this to persist after a system restart)

To stop the Apache server on OS X

sudo apachectl stop

or

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

(again, drop the -w if you don’t want this to persist after a system restart)

To restart the Apache server

sudo apachectl restart

It is important to note these particular commands are persistent. Meaning, if you start Apache using the first or second command above, it will persist through a system restart (i.e. Apache will restart after you restart OS X). Likewise, if you stop Apache with the third or forth command above, it will persist through a system restart. You can drop the -w from the second and forth command if you don’t want it to persist through a system restart.

Recent Articles

spot_img

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox