# Serve current directory on port 8000
python3 -m http.server 8000
# Bind to a specific interface (e.g., localhost only)
python3 -m http.server 8000 --bind 127.0.0.1
# Serve a specific directory
python3 -m http.server 8000 --directory /path/to/dirpython -m SimpleHTTPServer 8000# Serve current directory on port 8000
php -S 0.0.0.0:8000
# Serve a specific directory
php -S 0.0.0.0:8000 -t /path/to/dirruby -run -e httpd . -p 8000Install once:
npm install -g http-serverThen:
http-server -p 8000For systems with BusyBox (common in minimal Linux distros):
busybox httpd -f -p 8000Warning: Only serves a single file (no directory listing) and exits after one request:
# Serve a single file (e.g., index.html)
{ echo -ne "HTTP/1.0 200 OK\r\n\r\n"; cat index.html; } | nc -l -p 8000Install:
sudo apt install webfs # Debian/UbuntuRun:
webfsd -F -p 8000Install:
sudo apt install darkhttpd # Debian/UbuntuRun:
darkhttpd /path/to/dir --port 8000Serve a single file:
socat TCP-LISTEN:8000,reuseaddr,fork SYSTEM:"echo HTTP/1.0 200; echo Content-Type\: text/plain; echo; cat index.html"Generate a self-signed cert:
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365Run Python server with SSL:
python3 -m http.server 8000 --bind 0.0.0.0 --directory /path/to/dir --certfile cert.pem --keyfile key.pemCaddy is a full webserver but it can be used in a oneliner.
caddy file-server --listen :8080With Browsing Enabled (Directory Listing)
caddy file-server --listen :8080 --browse- Quick Testing: Python or PHP servers (e.g.,
python3 -m http.server). - Single File:
ncorsocat. - Minimal Overhead:
busybox httpdordarkhttpd. - SSL: Python with self-signed certificates or Caddy
- Most servers bind to
0.0.0.0(all interfaces) by default. Use--bind 127.0.0.1(Python) or-l localhost(darkhttpd) for local-only access. - Stop the server with Ctrl+C.
- These are not secure for production use (no auth, rate limiting, etc.).