How do I start apache in OSX Mountain Lion / Mavericks?
Solution 1
The LaunchDaemon for Apache is still there as well, so all you have to do it load it:
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
The -w
makes it permanent, i.e. it'll be reloaded when you reboot.
Solution 2
Terminal Commands
Starting: "sudo apachectl start"
Stopping: "sudo apachectl stop"
Restarting: "sudo apachectl restart"
Launching on Startup
(See the marked answer in this thread)
Solution 3
sudo apachectl start
also enables the launchd daemon. It overrides the Disabled
key in /System/Library/LaunchDaemons/org.apache.httpd.plist
by modifying /private/var/db/launchd.db/com.apple.launchd/overrides.plist
, just like launchctl load -w
.
For http://localhost/~username/
to work, you have to create
/etc/apache2/users/username.conf
and add a <Directory>
directive like
this:
<Directory "/Users/username/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Solution 4
Slifty and Lauri hint at an important concept without clearly saying it.
"sudo apachectl start" will not only start apache but will also modify /private/var/db/launchd.db/com.apple.launchd/overrides.plist so that apache will automatically restart each time the system is rebooted.
Similarly, "sudo apachectl stop" will stop apache and modify the above file so that apache won't start when the system is rebooted.
This seems to be the simplest way to control whether the service starts automatically.
Solution 5
For those in search of a GUI, Click On Tyler has developed a control panel app, http://clickontyler.com/blog/2012/02/web-sharing-mountain-lion/
Related videos on Youtube
slifty
CMU and MIT graduate, Open News alum, worked at the Internet Archive, Boston Globe, Mozilla. Currently a Corporate Overlord at Bad Idea Factory where I develop open source tools to help people thinking face emoji. A lot of what I do is related to journalism and media analysis.
Updated on September 18, 2022Comments
-
slifty over 1 year
OSX Mountain Lion removed the GUI for web sharing, but apache is still installed.
How do I start and stop the service? How do I get the service to automatically launch on startup?
-
Wojciech Bednarski almost 12 yearsIts starts automatically, at least for me. Just type 0.0.0.0 it should be there.
-
Wojciech Bednarski almost 12 years@Lri No. I did upgrade from 10.7
-
-
Rich Homolka almost 12 yearsIs there an equivalent ShutdownItems dir? Don't have OSX in front of me at the moment...
-
slifty almost 12 yearsThere used to be /etc/rc.shutdown.local -- not sure if that is still around...
-
James McMahon over 11 yearsHow do you turn this off once it's started this way?
-
Gordon Davisson over 11 years@JamesMcMahon:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
-
James McMahon over 11 yearsHmm, something is still running on localhost, I had assumed it was Apache, maybe I have something else running.
-
Gordon Davisson over 11 years@JamesMcMahon: You can use e.g.
sudo lsof -i:80
to see what process is listening on a given port. From there, this previous answer might help you track it down... -
Dilip Rajkumar over 11 yearsNice widget.. however in my system something went wrong and apache is not starting..:(
-
emotality about 9 yearsTo Delete:
~/Library/PreferencePanes
-
Motti Shneor over 7 yearsSorry, this is no longer available, or became part of a commercial product that you can only download complete - not just the preference panel. Any alternatives?
-
Motti Shneor over 7 yearsThis rather ugly UI's preference panel crashes immediately as you try to start the web-server on both OS-X 10.11 and 10.12. Crash-logs available at your request ;)
-
James McMahon over 7 yearsHonestly better to use
ngnix
at this point.