8

On my Mac OS X, Web Sharing is disabled in System Preferences -> Sharing -> Services -> "Personal Web Sharing". Still, when I type "localhost" in the browser, I get the "It works!" message, meaning that Apache is still running. How do I disable it?

Currently the bundled Apache port 80 is conflicting with my MAMP installation, since I want MAMP to run on 80.

4 Answers 4

6

Disabling Web Sharing in System Preferences should disable Apache.

However, make sure that when you load "localhost" in your browser, that you force a refresh rather than your browser loading the cached response from when Apache was running. You can force a refresh by Command-Shift-R in many browsers (as opposed to Command-R for a normal refresh).

Additionally, you can verify that Apache is no longer loaded by running this command in Terminal:

ps aux | grep httpd

If Apache is loaded, you will see a ps entry for

/usr/sbin/httpd
5
  • You can also kill apache manually if it's just hanging on for some inexplicable reason, but I would suggest rebooting the machine first (If apache starts at reboot something still thinks it should be running - No idea what, but we could start looking for other ideas...)
    – voretaq7
    Jun 1, 2011 at 15:44
  • Disabling web sharing merely prevents access to the web server from other machines. It doesn't disable Apache. Jun 2, 2011 at 21:49
  • 1
    Strange. On my 10.8.3 setup I no longer have "Web Sharing" in the list, but everytime I 'killall httpd', the /usr/sbin/httpd process reappears after a couple of seconds. Apr 27, 2013 at 14:38
  • 1
    @NicholasTolleyCottrell - You ever get that figured out? Where httpd keeps restarting itself. That's pretty annoying...
    – jmort253
    Mar 18, 2014 at 17:15
  • 1
    Not sure why this answer was accepted. It doesn't fix the problem. "Web Sharing in System Preferences" isn't even a thing anymore, if it ever was.
    – geoidesic
    Mar 13, 2021 at 14:44
22

It seems that Apache on 10.8 had decided to become active (perhaps after a minor update). Found that you can run the following command to permanently disable Apple's Apache:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
1
  • 1
    just used this after httpd auto-started itself with config errors, so it wouldn't respond to sudo httpd -k stop - using macOS Monterey. thanks!
    – Sandra
    Nov 8, 2021 at 19:43
0

You could also simply try turning Web Sharing on and then back off. People forget that the interface does not always give you accurate information on the state of the system.

By turning Web Sharing on, you get the opportunity to turn it off and cause the system to do the steps associated with turning it off. Simply looking at the check box and seeing it is unchecked doesn't do that.

0

To prevent auto-start of apache server, use

sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

This will stop apache server to use port 80, unfortunately after you restart your macOS, Apache Server will summon itself again.

You can reuse above command after restart

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .