how to open a localhost server on a Mac

Here’s how you host a local site with a Mac computer:

  1. Open the Terminal and navigate to the folder with your site in it (you can find the Terminal app on the launchpad)
    1. You can move to the parent folder using the command cd..
    2. You can view all files in a folder using the command ls
    3. Navigate to a folder using the command cd foldername
  2. Enter the command php -S localhost:8080, this will open a localhost port using the folder you are currently in
  3. Visit localhost:8080 in your browser to view your website
  4. To close the port, open the Terminal app, press ctrl+c to quit listening, and then enter the command sudo lsof -i :8080

 

Advertisements