Skip to content

Instantly share code, notes, and snippets.

@thagxt
Last active December 2, 2022 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thagxt/2cbaf11d449ccb343ea4ffdf1c473d27 to your computer and use it in GitHub Desktop.
Save thagxt/2cbaf11d449ccb343ea4ffdf1c473d27 to your computer and use it in GitHub Desktop.
Run a local web server inside any folder on Mac, Window, Linux, PHP, Node.js

Node.js

# Install http-server module globally 
npm install http-server -g

# Navigate to any directory you want the server to run in
cd /path/to/dir/with/files

# Launch HTTP server
http-server

# Launch HTTP server on different port
http-server -p 8888

Now visit http://127.0.0.1:8080 to access your files.


PHP

If you have PHP 5.4.x or higher installed locally, you can launch a PHP server from any directory.

# Navigate to any directory you want the server to run in
cd /path/to/dir/with/files

# Launch HTTP server
php -S localhost:8000

Now visit https://localhost:8000 to access your files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment