How can I remove Apache2 that I have installed in Mac OS X?

Your question states you want to remove Apache2 from Mac OS X, but it’s not clear how you installed it or even if you did a custom install. If it’s the Apache that is installed with Mac OS X you don’t want to remove it from the OS, but just deactivate it so it’s not running.

By default Apache comes bundled with Mac OS X but it’s deactivated. So my assumption is you simply started Apache on the system and even set it to come up automatically when the system starts up or reboots. I’m guessing that since your output of sudo lsof -i:80 shows Apache running under the user _www.

Anyway to stop the built-in Apache server in Mac OS X is by using this command:

sudo apachectl -k stop

Then just enter your administrator password. And to prevent Apache from coming up again on if your system reboots/restarts just run this launchctl unload command; you’ll need your administrator password again:

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

When that’s all done, check the output of sudo lsof -i:80 and the built-in Apache web server in Mac OS X should be completely stopped and disabled.