Running a Local Server
published on
In this tweet Andy Bell mentions that you can run a local Python server with these easy commands:
- Open your Terminal
cd
to your project directory- Run
python -m SimpleHTTPServer
- Open your browser to localhost:8000
- Done
I didn’t know about the Python way, but another possibility is to run a PHP server, which is a similar process:
- Open your Terminal
cd
to your project directory- Run
php -S localhost:9090
- Open your browser to localhost:9090
- Done
As Zell points out, you can also run a server as a Node module.
- npm install -g http-server (do this once)
- Open terminal and type http-server
- 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!