When you’re building a website one of the most important steps is the building of the templates. Building static templates is almost always quicker than building integrated templates such as WordPress, Django or Rails.
One of the biggest issues with using static templates straight off the file system is that file:// urls can have issues and relative links may have to be different than what they need to be when the site goes live. A local server is what’s needed, but things like MAMP, or LAMP servers can be a pain to setup,esecially if your working on multiple projects. Enter the simple server.
PHP has a basic server. Simple go to your project folder in the terminal and run the following:
1php -S 0.0.0.0:8080
This will setup a basic php server on the address and port provided.
With all these simple servers you have to remember that there is no database so you can only do simple functions and serve files, but not do anything more complicated. That's not to say you can't also run a simple database and connect to that, but that's out of the scope of this article.
It's also worth noting that you can pass other options to the simple php server such as the timezone:
1php -S 0.0.0.0:8080 -d date.timezone=UTC
If you are using something other than PHP or you want an alternative way to do this there is also a Python version. From your command line just run:
python -m SimpleHTTPServer
and it’ll serve your local files off the local host: http://0.0.0.0:8000