Y because the Mac system comes with PHP and Apach by default,
So you can start the Apach service directly with sudo apachectl start,
At this time in the browser input http://localhost
, will appear it works!, that Apach open success.
However things didn't go so well when I followed the steps as above and entered Apach after the Google browser opened,
It's the following!
Troubleshoot the problem:
1. I checked the port take-up situation:
Use Lsof (list open files) under Mac to view port occupancy, lsof is a tool that lists open files for the current system.
Using Lsof lists all the ports that are occupied:
$ lsof
Use less to display pagination, such as:
$ leof | Less
You can also use-I to see if a port is occupied, such as:
$ leof-i:8080
If the port is occupied, the relevant information is returned and no information is returned if it is not occupied.
2, directly with Nginx instead of Apach
First I close Apach
$ sudo appachectl-s stop
Turn on Apachsudo apachectl stop
and started the Nginx.
$ sudo nginx
Find out or can't open localhost
Close Nginx
$ sudo nginx-s stop
Finally found in Safari browser input localhost can actually open!
Only found that the original Google browser opened the agent, the agent can be closed.
Mac os php www folder/library/webserver/documents/
Detailed Configuration link: https://www.jianshu.com/p/2fb9a3bb12f6
Workaround for Mac to open Apach but cannot access localhost