macOS closes apache httpd and starts it up
macOS installs the apache httpd service by default, and it will start automatically at boot, occupying port 80. If you do not need the httpd service, you can close the apache httpd service and cancel the automatic startup at boot.
Execute the following command in the terminal:
sudo lsof -i:80
Check which process is using port 80
The results are as follows:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 18183 root 4u IPv6 0x455b25acea0abc45 0t0 TCP *:http (LISTEN)
httpd 18187 _www 4u IPv6 0x455b25acea0abc45 0t0 TCP *:http (LISTEN)
Execute the shutdown startup command
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
The results are as follows:
/System/Library/LaunchDaemons/org.apache.httpd.plist: Operation now in progress
The startup command is as follows:
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
start apache command
sudo apachectl start
restart apache command
sudo apachectl restart
stop apache command
sudo apachectl stop