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.

Sorry if I spammed your RSS feed

Hey everybody who’s on my RSS feed (all 4 of you), I’m sorry If I spammed your feed with all of my posts being reposted. I just moved my WordPress to a new server, which should be faster and better. This will also let me get updates from WordPress faster, since I’m now running Debian Testing instead of Ubuntu for my server.

All in all, it should be a better experience for all of us. Thanks!

Under construction

As you may be able to tell, my blog theme now looks very very basic.  Well, for all intents and purposes, it doesn’t have a theme right now.  I’m a compulsive tinkerer, and so I’ve decided that I’m not happy with any of the themes that are currently out there.  So, in order to have some fun, have some more control, and to learn some more, I’m going to create my own theme, based off of the WordPress Default theme.  So, hopefully, this will start to look better as I continue to learn and write more.

(I wanted to have one of those animated .gifs of an under construction sign with a guy digging, but I felt that was a little too 1996.)

ha!

Ha ha!

I FINALLY got www.shadeball.org to redirect to http://shadeball.org. And you know how I finally ended up doing, after days of strife and anger and stupidity?

sudo ln -s /etc/wordpress/config-shadeball.org.php /etc/wordpress/config-www.shadeball.org.php

Thats all. 10 seconds, and it was fixed. UGH

Finally up and running

Alright. I’ve finally got my new WordPress site up and running. I switched from Drupal to WordPress because WordPress looks better, and it does the things I want to do built in instead of having to work at it for a long time with Drupal. Drupal’s a great piece of software, but its not what I need right now. Its actually kind of similar to my switch from Debian to Ubuntu. I really liked Debian, but I finally got sick of taking hours to do the things that Ubuntu does built in. Yeah, I’m sacrificing some freedom, but its mine to sacrifice.

But yeah. I had to install WordPress three different times, because I’m bad at life. The first time I installed it on my Debian server, but I had somehow borked up my MySQL and couldn’t figure out how to fix it so I just installed a Ubuntu server. Then I got everything up and running and working well, until I changed an option that tried to redirect everything to www.shadeball.org, which isn’t supported right now(although I’m trying to fix that).

How-to: Basic informtaion to get a GoDaddy site working on a Ubuntu server

Here’s what I needed to do to get my custom domain name from GoDaddy working with this WordPress instance on an Ubuntu 9.04 server. After installing and setting up WordPress, which was mostly easy, I needed to get this custom domain name working as well. The first thing that I needed to do was to edit my /etc/hosts file. When I installed Ubuntu, I just okey’d the default networking settings, which set my domain name as nc.rr.com. So I had to change that to shadeball.org, to match this website. I also changed the IP address in the hosts file from 127.0.1.1, a loopback address, to its real local address, 192.168.1.105. To finish the /etc/hosts file part, I ran these two commands: echo grainger.shadeball.org > /etc/hostname and /etc/init.d/hostname.sh start. Then I needed to change the settings of my Apache webserver. The first thing that I changed was the document root, so that it was actually serving up my WordPress site instead of placeholder “It works!” that is in the default installation of any Apache webserver. After I changed the document root to “/usr/share/wordpress”, I had to add the ServerName and ServerAlias fields so that it would actually run as “shadeball.org” and “www.shadeball.org”. So I added: ServerName shadeball.org ServerAlias www.shadeball.org into the top of the VirtualHost area. This actually doesn’t work, so far as I can tell, with WordPress. I want to figure out how to get it so www.shadeball.org does actually redirect to shadeball.org, but I haven’t figured it out yet (and borked my server trying). To make my site accessible to the world, I only needed to change a few more things, all in my GoDaddy DNS settings. In the “Total DNS Control and MX Records” page, I changed the Host to the IP address of my server, and changed the “www” alias to “shadeball.org”. And then that was that!

This will prove useful for me if/when I ever install a new server, and I hope it can be useful to anyone else installing a server. I couldn’t find a really simple explanation of how to get a custom domain name working on a personal server.