Build a local server on Mac

MacOS comes with Apatch server. So I choose Apatch server to build here

1. Start the server

  1. Enter http://127.0.0.1/ in Safari. If it works on the page, it means the access is successful.
  2. Start the server
$ sudo apachectl start
  1. Restart
$ sudo apachectl restart
  1. closure
$ sudo apachectl stop
  1. Apache server file address:
    /libary/webserver/documents/

2. Add files to local service

  1. Prepare an html file

  2. Add to the address of the Apache server
    Insert image description here

  3. Enter http://127.0.0.1/test in Safari to see the saved image

3. Access the local server from your mobile phone/other computers

1. Find the IP address of this machine: Open Settings-Network, you can see your IP
Insert image description here

Enter http://192.168.9.109 in this machine's Safari to access the same effect as http://127.0.0.1
2. When testing on mobile phones and other computers, you must ensure that the mobile phone and other computers are in the same LAN as this machine
. Enter http://192.168.9.109/test in Safari to access successfully.

Guess you like

Origin blog.csdn.net/guoxulieying/article/details/132709351