Working on PHP ? Python ? Node.js ? Ruby ? These simple commands will spin a local webserver for you in seconds. Some we don’t need to start entire server setup to run some simple tests or snippets. In such cases this is very useful.

PHP

This command will work only on PHP 5.4+ versions. At the site root directory, Run php -v on your terminal / command prompt to check php version.

Local server will be available at http://127.0.0.1:8000

# Required PHP 5.4+ 
$ php -S 127.0.0.1:8000

Python

If you use Python 2.x version you can use SimpleHTTPServer to start a webserver. Local server will be available at http://127.0.0.1:8000.


$ python -m SimpleHTTPServer 8000

For Python 3.x versions:


$ python -m http.server 8000

#Install Dependency
$ npm install http-server -g

$ http-server -p 8000

#Install Dependency
$ npm install -g serve

$ serve -p 8000


$ ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.pwd).start'


For Ruby 1.9.2+ versions you can simply use the below command.


$ ruby -run -ehttpd . -p8000