Local web server

How to start a simple web server

Python

python -m http.server $PORT
# ex: python -m http.server 8040

PHP

php -S localhost:$PORT -t $DIR
# ex: php -S localhost:8000 -t /var/lib/www

RUBY

ruby -run -e httpd . -p $PORT
# ex: ruby -run -e httpd . -p 8080

NC

while true ; do nc -l 80 <$HTMLFILE ; done 
# while true ; do nc -l 80 <index.html ; done 

Last updated

Was this helpful?