Introduction: Host Your Own Blog From a $25 Raspberry Pi Computer

Picture of 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. 

Human requirements:
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
4) Patience

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

Picture of 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:
http://www.raspberrypi.org/quick-start-guide

You'll be installing the latest "Raspbian" SD card image from here:
http://www.raspberrypi.org/downloads

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:
http://www.penguintutor.com/linux/raspberrypi-headless

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

Picture of 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:

http://www.penguintutor.com/blog/viewblog.php?blog=6306

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

Picture of 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:
http://pelican.readthedocs.org/en/3.0/getting_started.html

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!
http://wiki.python.org/moin/BeginnersGuide/Download

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.  

Step 4: Setup PageKite

Picture of Setup PageKite

When I first setup my rPi server, I tried using Dynamic Dns (through NO-IP.com) to make it work. It didn't. The reason was that my ISP, RCN cable, blocks all incoming requests on the http port - port 80. I thought that since No-IP has a service that will redirect those requests to another port of my choice (I used 8080), that'd I'd be ok. 

But this had the very bad effect of making the non-standard port # I chose appear in my URLs. So when visiting my site, instead of seeing: 

http://amosamos.net  

in the address bar, the viewer would see:

http://amosamos.net:8080 

That's enough to freak out most parents, grandmothers, and folks who are liable to get freaked out by the webs and viruses and hackery. I could avoid this by paying my ISP $20 more a month for a static IP, but that seems like a lot to hose a simple blog. I like them, for the most part, but not that much.

Luckily, a friend told me about PageKite. PageKite allows you to install their app - written in Python - on your webserver. It keeps in contact with PageKite's front end servers. So when a request to view your website comes in, it gets forwarded from the PageKite servers, through a "tunnel" to your rPi's localhost port 80. So there's no need to use Dynamic DNS to keep track of what IP address your ISP has assigned you today, or hop around the blocks they may or may not have installed.

http://pagekite.net/

PageKite is pay what you want, and the suggested rates are very low (~$3 / month). 

Step 5: W00t! Homegrown Webs...

Picture of W00t! Homegrown Webs...

Now send your url to all your pals, and fill the internets with your homegrown, homeserved wisdom. :)

Next steps?

* Setup your rPi to use autoupdate. That means that it will install security patches / updates automagically, to ensure that any security holes get plugged up quick. Here's a great tutorial:
http://www.howtoforge.com/how-to-configure-automatic-updates-on-debian-squeeze

* Make your rPi run on solar power, so you can serve solar powered content round the world. (You only need around 2 watts!) Then make an instructable!


Comments

amandaghassaei (author)2012-09-05

cool! do you have anything up right now that's hosted by a rpi?

franson (author)amandaghassaei2012-09-05

here is similar mini server based on arm cortex a8 samsung s5pv210:
http://www.quickembed.com/Tools/Shop/Solution/201209/261.html
soon will have an rpi version!

franson (author)franson2012-09-05

a picture

supportnumber12 (author)2017-06-27

Thank you for sharing this tutorial which is very informative.


McAfee Tech Support
DavidR144 (author)2017-01-24

Nice job on the tutorial

alexmac131 (author)2014-01-10

tips: unless your doing intense video lower it's memory 2) use only class 10 SD cards for speed 3) 1amp power supplies the older apple USB supplies work best 4) Apache runs fine on the pie 5) label your SD cards 6) change the raspberry pi and root passwords to different from each other values

bobrob5k (author)2012-11-10

any idea what sort of traffic it can handle?

AmosLightnin (author)bobrob5k2012-11-10

It should be able to handle a fair amount, since all it is doing is serving static files.

PoulGrym (author)2012-10-27

I gave it a good try, here is where I got stuck. First to put phython part above would saved me a bit of time to figure it out. Still not sure the order of install PIP or Easy_Iinstall or how virtualenv works or is. With no real experiance of linux that well. I couldn't save anything in /var/www .. Some feedback. I'm sure I'll work it out and thanks for writing this, just hit my first hurdle I just hope I don't land on my face.

Cheers!

AmosLightnin (author)PoulGrym2012-10-28

Hi PoulGrym!
re: Putting python first: good idea - I'll see about editing this!
For installing python (it may even be already installed), it might be as simple as typing:
sudo apt-get install python

Give that a go, and if it works I'll update this to use the shorter instructions.

As to installing Pelican - try:
sudo pip install pelican

The "sudo" before a command stands for "super user!" - the user who has all permissions on your system. It tells the system to execute the following command as if you were the superuser - or God - of this machine. On Debian / Ubuntu type of Linuxes, you'll generally need to use "sudo" before commands that install stuff, because only the super user has the necessary privileges to install stuff on the computer.

Copying files to /var/www should also work if you type sudo before the command. Just be careful - playing god with sudo means that if you say "sudo (do something that will totally hose my machine)", it will say "Yessir, of course sir!" and proceed to hose your machine. :) Of course, if that happens, just start over - it's a great way to learn, if sometimes a little disheartening.

whatthewaffle (author)2012-09-30

there's this really nice site that will give you free domain names. it's really handy. dot.tk

AmosLightnin (author)2012-09-13

Testing... hmm, I know I replied to that first comment by amanda, but it's no longer visible. Wonder why?

About This Instructable

40,761views

112favorites

License:

Bio: I develop tinkering activities that invite people to experience and reflect on creativity and learning through play. Previously I ran the Scratch online community in ... More »
More by AmosLightnin:Pallet Christmas tree standClothes Drying Rack Out of Pallets and ParacordBathroom shelf made of pallet wood
Add instructable to: