Since the development of the Raspberry Pi (model A came out in 2012) I’ve been intrigued by it. Although I had a first generation model A and a second generation B+ laying around, it is just until recently that I’ve been actively using it. It is all over JvdC.me that I use Digital Ocean (and more recently Vultr) as my go to ‘VPS’ provider. They are scalable, affordable and unmanaged.
Nothing can beat your very own dedicated home server though. I’ve successfully tried it with the newest (anno 2016) Raspberry Pi 3 (third generation) B and I’ll try to explain the whole process I’ve went through.
→ A Raspberry Pi
→ An empty micro SD card of at least 8GB
→ Power supply, screen with HDMI, HDMI cable, keyboard and mouse
→ Know how to connect to a server (Terminal, Putty,…)
Step 1: Getting our OS
In this first part we will start with flashing the Raspbian OS on our SD card. The Raspberry is very versatile and you can install a whole range of operating systems on your Raspberry. After experimenting with both Ubuntu and Raspbian (and reading a whole lot about both and other OS’s), I concluded that Raspbian is the best fit for setting up a web server (naturally). Raspbian is based on Debian and optimized for the Raspberry Pi. You can download the latest version from the Raspberry Pi website itself.
When writing this guide, the latest version is Jessie (Debian 8). We do not need the full desktop image for a web server, the Lite version is perfect for our application. We will install the packages we need afterwards. So go ahead, download the image and unzip if necessary. Place somewhere easily accessible (home folder, desktop…).
Step 2: Flash the image to SD
Now we will ‘flash’ the Raspbian image to our micro SD card. Let’s start with Mac. Grab your MicroSD card and insert it into your computer (with adapter if necessary). Now we need to know the know the disk number of our SD card. This is done by using the following command:
The output is a list of all the volumes and disks inside or connected to your computer. The hard drive of your computer will in most cases be the first one listed as
/dev/disk0. Look for your SD card, either by checking the size, type or name. Note down the disk identifier, for example
Before we can write anything to the SD card, we need to unmount it by using the disk identifier:
diskutil unmountDisk /dev/disk1
To put the Raspbian image on the SD card we will use the
dd command-line utility (for Unix and Unix-like OS’s). The command looks as follows:
sudo dd bs=1m if=[path to downloaded image] of=/dev/rdisk[disk identifier from diskutil]
You can click and drag your download image file to the terminal and it will automatically input the path to that file. For example:
sudo dd bs=1m if=/Users/Jonas/Desktop/2016-03-18-raspbian-jessie-lite.img of=/dev/rdisk1
It can take quite some time (10 to 15 minutes). You can check the progress by pressing Ctrl+T. Getting
dd: invalid number '1m' error? Replace 1m with 1M. Still getting errors? Replace rdisk with disk.
To flash an SD card on Windows there is a very easy to use program called
Win32DiskImager. You can download it here and simply follow the steps (select SD card, select which image and of you go).
Now you should have a fresh SD card with the most recent of the best (personal opinion) operating system there is for Raspberry Pi. Next up: configuring Raspbian on Raspberry Pi and make it usable in ‘headless’ (no physical keyboard, mouse or display attached to it) mode.