How to easily start a webserver in any folder?

Use

python2 -m SimpleHTTPServer 80

or

python3 -m http.server 80

to start a simple HTTP server.

Replace 80 with another number if you want it to listen on a different port. For ports < 1024 it needs to run with root privileges.


I also like to use PHP for this purpose, as it enables me to run stuff like WordPress on the fly and develop themes more easily (you still need MySQL, though):

php -S 0.0.0.0:8000

In the same script that starts this I also start guard, which auto-refreshes the browser on file change.


if you are more ruby minded, the serve gem is great

serve

or for i different port:

serve 9000

install with gem install serve

Tags:

Webserver