Host your own blog from a $25 Raspberry Pi computer
Now everybody knows it’s way smarter to just pay someone to host your website. But what not everybody knows is that it’s way more punk rock to Do it Yourself. So what follows are some tips / pointers / instructions for setting up your own home webserver (which will burn a scant 2 watts) using all free, open source software, a Raspberry Pi, and your home internet connection.
The emphasis here is on lightweight, which fits well with the Raspberry Pi. Sure, you can setup a blog with wordpress or Django, and they will run (I’ve tried it, at least with Django). But they probably will run rather slowly. Why? The rPi doesn’t have a lot of memory or processing power, and a database / front end model requires a decent amount of that. If your site / blog ever gets much traffic, it’ll likely buckle under the load. The answer? Just serve up plain old static HTML pages. It’s fast, secure, simple, and easy on the rPi’s limited resources. But rather than painstakingly handcodeing each new blog entry, you can use a static html generator like Pelican to make it easy.
Here are the hardware ingredients:
1) A Raspberry Pi (with power supply and SD card)
2) A computer with an SD card reader (or a USB stick SD card reader)
3) A simple home network, shared by your computer and the rPI. If you have a router and an internet connection, you’re golden. The rPi will need to be connected via ethernet, so you might need a cable.
Here are the main software ingredients:
1) The standard Raspberry Pi Linux “Raspbian” operating system, based on Debian.
2) Lighttpd, a lightweight web server, that’s pretty easy to setup.
3) Pelican – a static html blog generator (you can also use something like Octopad, if you prefer.)
4) PageKite – a “localhost tunneling solution,” which I found to be much better than dynamic DNS.
1) Some linux know how, or
2) A friend with some linux know how, and / or
3) Know how to use forums to ask for help, and
This instructable won’t be comprehensive, but it will point you to the resources / places to get help if you need it.
Step 1: Setup your rPi
First you need to setup the SD card on your rPi. On this little computer, the SD card is your hard drive. It needs an operating system so you can boot and run your rPI, and tell it what software to run to serve your site.
Check out the getting started guide here:
You’ll be installing the latest “Raspbian” SD card image from here:
Follow the instructions to download the image and install it on your SD card.
Now, if you have a monitor, keyboard, and mouse that you can use to run your rPi, you’re set. If you don’t, it’s ok – you can still set things up from the command line in what’s called “headless” mode. To do that, you’ll need to “SSH” into your rPi through the network connection shared by it and your computer. Here’s a great tutorial that explain how to do that:
Do run the Pi setup script when prompted.
You’ll want to change the default password! If you leave the username as ‘pi’ and the password as ‘raspberry,’ you will be pwned. Change it now to something strong – web servers are exposed to the big bad internets, so you’ll want to be security conscious.
Step 2: Setup a static IP, then install a webserver
Now you’ll want your rPi to have a static IP address on your local network. Most networks use DHCP by default. That’s a system where the router gives out an available IP address when asked by each computer. It’s easier to setup your rPi to ask for the same IP every time. Here’s another good tutorial from penguin tutor on how to set that up:
Once you have a static IP, install the webserver!
It’s very easy to install software on Debian (and Raspbian is just Debian optimized for the pi), because pretty much all the software you need is available in the Debian software repositories. So just open a terminal and type:
sudo apt-get install lighttpd
Lighttpd (pronounced “lighty”) is a lightweight open source web server. Its job is to listen for requests from the internet on the http port – port 80. When it receives a request, it sends back the requested webpage data.
Once lighttpd is installed, you should be able to see a startup web page by typing your rPi’s IP address into your browser’s address bar. For example, if you chose 192.168.1.20, you just type that into your address bar, and lighttpd’s default webpage will come up. (If it doesn’t at first, try rebooting your rPi: sudo reboot )
Step 3: Pelican, a static html blog generator
Pelican is an awesome static html makin’ blog engine. What does that mean?
It means that once you set it up, you write blog posts in your favorite text editor, place them in a special folder, and then run Pelican. It then converts your text files into a simple HTML website on your computer. You then copy those files to your rPi server, and your viewers will be able to navigate through your posts. You can even choose different themes.
Pelican setup is described here:
You’ll need to first get python – the programming language in which Pelican is written and on which it runs – installed on your computer. The good news is that there are good instructions on how to do that on the webs. It might already be on there!
The simple theme that comes with Pelican is pretty good, but there are a few others to choose from (see links on the site). You can also roll your own if you have some html / css chops.
Once you’ve generated your blog, you’ll want to copy it to your rPI’s /var/www directory – that’s the directory where Lighttpd looks for html pages to serve when it gets http requests. Pelican has lots of handy utilities to make that easy, including synching through drop box, or copying the files via ssh.
For more detail: Host your own blog from a $25 Raspberry Pi computer