Juicy lil' bytes

Simple One-Line Local HTTP Servers

Here’s a collection of one line commands that will start a local HTTP server for static files.

PHP

1
php -S localhost:[port] -t [root-path]

Example

1
php -S localhost:8080 -t ./_build

Python

Python 2.x

1
python -m SimpleHTTPServer [port]

Example

1
python -m SimpleHTTPServer 8080

Python 3.x

1
python -m http.server [port]

Example

1
python -m http.server 8080

Ruby

1
ruby -run -e httpd . -p [port]

Example

1
ruby -run -e httpd . -p 8080

Documentation

PHP

Python 2

Python 3

Ruby Webrick

Sources

Thanks to Adriano Guerrero for the PHP command and to Dallas Reedy for the Ruby command.