When using mac os for web development, you will encounter the situation that port 80 is already occupied. This problem can be solved through the following steps.
1. Use lsof -i:80 to check the processes currently occupying port 80, and kill them if there are any. (Recommended learning: apache use)
2. Turn off the startup of mac’s own apache.
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
If you want it to be started one day, change unload to load:
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
3. This is also the most common one. Mac prohibits ordinary users from accessing 1024 The following ports, including port 80. If you want to access through port 80, you need to use port forwarding. The command is as follows:
sudoipfw add fwd 127.0.0.1,1081 tcp from any to 127.0.0.1 80 in
It roughly means to do port forwarding, port 80 to 1081, so that the web services point to 1081 of nginx (equivalent to the original port 80)
About ipfw command:
a. View rules: sodu ipfw list
localhost:sbin lq$ sudo ipfw list 00100 fwd 127.0.0.1,1081 tcp fromany to 127.0.0.1 dst-port 80 in 65535 allow ip from any to any
b. Delete rules: sodu ipfw delete 100 [The deletion rule is: 00100 fwd 127.0.0.1,1081 tcp from any to 127.0.0.1 dst-port 80 in】
c. New rule: sudo ipfw add fwd 127.0.0.1,1081tcp from any to 127.0.0.1 80 in
The above is the detailed content of How to stop apache that comes with the system. For more information, please follow other related articles on the PHP Chinese website!