Do you need a simple web server at home? If you have a low budget, you don't need a supercomputer and you don't want to buy a cloud virtual server account, this is the solution that's right for you.
A super combo webserver combination of instruments:
1. Prepare your Rapberry Pi (with SD card 16GB class10 or greater)
Download the raspberry pi OS following this guide here:
IMPORTANT: prevent the Raspberry pi SHOCK overheating by installing a heat sink cooler and a 5v fan.
Install the raspbian os (easier and faster than the others). Connect keyboard, ethernet (or wifi), mouse and monitor. Expand the partition and set the current location for the timezone from the raspconfig menu, and startx (if you want to go in windows style).
Open terminal window and make a:
- sudo apt-get update
- sudo apt-get upgrade
Install SSH package to take control from remote (if not present):
You should now access to the raspberry from your pc via ssh. For windows bash link command-console you can use putty.exe
Create a user with the adduser command or use pi default user: pi@raspberry
type python in your shell. If you get:
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
it's ok, and go to the step 3. Otherwise install python 2.7 with sudo apt-get install python. Check python after installation and go to the step 3.
Here the setup part:
First things first, install Tornado on your Raspberry Pi:1. Good thing to do before every install – update agt-get and installed packages
sudo apt-get update
sudo apt-get upgrade
|
2. Install easy_install and pip (which are Python package managers)
sudo apt-get install python-pip python2.7-dev
|
3. Update your easy_install (and pip) package definitions
sudo easy_install -U distribute
|
4. Now install Tornado using pip
To make sure everything works, create a file named “server.py” containing the following code (taken from Tornado’s site), and run it from terminal using the command “python server.py”
| import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8080)
tornado.ioloop.IOLoop.instance().start()
|
Now on a separate computer on the same network, navigate your browser to http://raspberrypi:8080 (or use the IP address for example 192.168.1.7:8080). You should see “Hello, world” if everything goes right.
4. Install NGinx (optional - increase performances)
Open a terminal and execute:
sudo apt-get install nginx
setup nginx... (coming soon..).