Hosting your website on a Raspberry Pi

A couple of years ago, I hosted this website and a couple others on my first-generation Raspberry Pi. However, it didn't quite have enough power to even support my light usage, and so I went over to DreamHost (started with a very cheap promo deal, which went up to $120 in my second year). This year, my second renewal at the $120 level was coming around, and I thought that that was a lot of money to spend on my website when I have the skills to host it myself. In the intervening years, I had purchased a Raspberry Pi 2, and it really is a great option to host a website on. With 1GB of RAM and a 900 mHz ARM chip, the power that you're getting is actually fairly similar (or even better) to what the lowest tier paid hosting sites are giving you. With that in mind, I went back to my Raspberry Pi to get it going and replace my paid hosting with a computer that sits behind my television. The first thing that I did was to download Raspbian; it is the primary supported Raspberry Pi distribution, and I have a long history with Debian. I did make sure to disable the graphical user interface since I don't need that on a server and so it runs with a little less overhead. Debian stable is always a great base off of which to build a server, and the current version of Raspbian is built on Debian Jessie. I'll leave it to the documentation of Raspbian and Raspberry Pi themselves to tell you how to install your system. I've wanted to try out using nginx for a while, but with a time crunch before my DreamHost payment was due, I just went for the old standby: Apache. I can configure Apache in my sleep these days, and so it went quickly and easily. After doing an "apt-get install apache2" and a "a2enmod rewrite," you should be ready to create you site configuration file. In the past, I used to struggle to to find the right settings to make the permalinks pretty, but I've finally found the right site config to make either simple. Copy that template into your /etc/apache2/sites-available folder, and name it something like yoursitename.org.conf . Change all of the information to match your site, and then run "a2ensite yoursitename.org" to activate it. You'll also need to run a "service apache2 reload" to get Apache going. You'll need to put your whole site in the document root found in the site configuration file above. You can hand write HTML in there, or you can go for a full CMS like Wordpress, Drupal, Ghost, or many, many others. Once you've put the files there, I recommend changing the owner of the files to the www-data user; it helps provide some security should your site be attacked. "chown -R www-data /var/www/yoursitename.org" should get that done for you. On this site, I installed MariaDB (a drop-in replacement for MySQL) and then WordPress, but your choices are endless. I have two sites running on a single Raspberry Pi right now, with a third coming shortly; a "free -h" shows that I'm using 182 MB of memory right now. IMPORTANT UPDATE: Now, to get your site viewable on the larger internet, you have to get your DNS settings straight. Go to your domain name registrar (I use Hover), and go to the DNS tab. Find out what your public IP address is: you can either do it by logging into your router and poking around in there or by Googling and going to one of those sites that tell you. I was not really able to get IPv6 to work by itself, so I added both the IPv4 and IPv6 address to my registrar's DNS record. You put your IPv4 address in an A record, and the IPv6 in a AAAA record; I just left the hostname part blank and just added the addresses. Once you save those it should take about a half hour or an hour for the new location of your address to populate to all the DNS servers around the world, and then typing in "yoursitename.org" should actually take you to your site. Your public IP from your ISP may change from time to time, so if your site is suddenly not working check this first. A Raspberry Pi 2 is a pretty good option for hosting a fairly-low activity site, like a your personal resume, personal website, or a website when you're just starting out and don't want to pay for hosting.