# 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/dir
python -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/dir
ruby -run -e httpd . -p 8000
Install once:
npm install -g http-server
Then:
http-server -p 8000
For systems with BusyBox (common in minimal Linux distros):
busybox httpd -f -p 8000
Warning: 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 8000
Install:
sudo apt install webfs # Debian/Ubuntu
Run:
webfsd -F -p 8000
Install:
sudo apt install darkhttpd # Debian/Ubuntu
Run:
darkhttpd /path/to/dir --port 8000
Serve 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 365
Run Python server with SSL:
python3 -m http.server 8000 --bind 0.0.0.0 --directory /path/to/dir --certfile cert.pem --keyfile key.pem
Caddy is a full webserver but it can be used in a oneliner.
caddy file-server --listen :8080
With Browsing Enabled (Directory Listing)
caddy file-server --listen :8080 --browse
- Quick Testing: Python or PHP servers (e.g.,
python3 -m http.server
). - Single File:
nc
orsocat
. - Minimal Overhead:
busybox httpd
ordarkhttpd
. - 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.).