Three Simple Servers for Your Front-end Projects

Konstantin KomelinKonstantin Komelin

We can't open index.html file of some front-end projects in a browser because it requires a web server with a virtual host configured. On the other hand, configuring a separate virtual host for every front-end experiment is a waste of time. Of course, you can automate it but today you don't have to.

I'll show you how to run a simple web server using PHP, Python or Node.js with one command. Here we go.

First of all, open the console and go to your project directory. Something like this:

cd path-to-project

Working on LInux? You already have Python installed. So just run the following in the console:

python -m SimpleHTTPServer 8000

If you're a PHP developer your PHP interpreter is probably waiting for you in the console:

php -S localhost:8000

Used to develop apps on Node.js? Then http-server will come in handy. Install it globally:

npm install http-server -g

And run the server:

http-server --p 8000

The outcome of these commands will be the same. You'll get your project available on http://localhost:8000. Enjoy!