Skip to content

Instantly share code, notes, and snippets.

@akaak
Last active January 6, 2025 16:17
Show Gist options
  • Save akaak/9152d5d14131a7231e7493eba8d27bfa to your computer and use it in GitHub Desktop.
Save akaak/9152d5d14131a7231e7493eba8d27bfa to your computer and use it in GitHub Desktop.
Local HTTP server on a mac(book)

How to run http server on your local?

as of Jan 2025, Option (1) still is my preferred way of running http server on my macbook!

1) Using Python

Python comes pre-installed on macOS and provides a simple way to start a local server:

  1. For Python 3:
python3 -m http.server 8000
  1. For Python 2 (older versions):
python -m SimpleHTTPServer 8000

After running either command, you can access your server at http://localhost:8000

2) Using Node.js

If you have Node.js installed:

  1. Install the http-server package:
npm install -g http-server
  1. Run the server:
http-server

3) Using PHP

If you have PHP installed, you can use its built-in server:

php -S localhost:8080

This will start a server accessible at http://localhost:8080

4) Using Apache (pre-installed)

macOS comes with Apache pre-installed:

  1. Start Apache:
sudo apachectl start
  1. Access the server at http://localhost

You can edit the default page in /Library/WebServer/Documents/

5) Using MAMP

MAMP is a free, user-friendly application that sets up a local server environment:

  1. Download and install MAMP
  2. Start the MAMP application
  3. Access your server at localhost:8888

6)Using Homebrew

You can install and run Apache using Homebrew:

  1. Install Apache:
brew install httpd
  1. Start the service:
brew services start httpd
  1. Access the server at http://localhost:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment