Running a Local Server Bookmark

In this tweet Andy Bell mentions that you can run a local Python server with these easy commands:

  1. Open your Terminal
  2. cd to your project directory
  3. Run python -m SimpleHTTPServer
  4. Open your browser to localhost:8000
  5. Done

I didn’t know about the Python way, but another possibility is to run a PHP server, which is a similar process:

  1. Open your Terminal
  2. cd to your project directory
  3. Run php -S localhost:9090
  4. Open your browser to localhost:9090
  5. Done

As Zell points out, you can also run a server as a Node module.

  1. npm install -g http-server (do this once)
  2. Open terminal and type http-server
  3. Go to localhost://8080

As with many things, the best way depends on what you are planning to do. What I like about the first two options, is that you can just run them and do't need to install anything to get going. The last option requires you to download an install the module (globally, hence only once), but still I prefer to not having to do this. Either way, enjoy running your local sites!