Host Websites on a Raspberry Pi

The Raspberry Pi 3 is capable of running websites. I have two WordPress-based sites, including this one, running on Raspbian LAMP (Linux/Apache/MySQL/PHP) on the same Raspberry Pi that perform very well. They’re fast to load and fast to navigate. Of course, your mileage may vary base on many factors: how many concurrent visitors do you average, what Internet connection is feeding the Raspberry Pi, etc.

This article walks you through everything necessary so that you end up with a Raspberry Pi, loaded with Raspbian, running WordPress that is secured and being backed up and that is configured to send email through Gmail SMTP servers.

Buy Raspberry Pi

The equipment I bought in 2018 is as follows. Research if there are new models.

Install Raspbian

This walks you through how to install Raspbian via NOOBS:

https://www.raspberrypi.org/documentation/installation/noobs.md

Install WordPress

This walks you through how to install WordPress:

https://www.makeuseof.com/tag/host-wordpress-raspberry-pi

Implement SSL Certificate

Free SSL certificates can be installed via Let’s Encrypt. Let’s Encrypt is an initiative backed by Google and many other industry leaders to help the world move towards having all websites encrypted.

Follow these instructions:

https://pimylifeup.com/raspberry-pi-ssl-lets-encrypt

Send Emails from WordPress

You’ll need to be able to send email from your WordPress site for administrative emails such as password resets but also if you want to send additional emails such as when someone fills out a contact form.

There are many ways to do this. The way I decided was to have the site send emails through Google’s SMTP servers. You just need a free gmail account to be able to configure it. One thing to keep in mind with this approach is that emails sent through your WordPress site will say they’re from your gmail address which may not prime if you want them to say they’re from your domain. I’m fine with that for my sites because I don’t except to send anyone emails other than to myself from my WordPress sites.

Follow the instructions here:

https://www.wpbeginner.com/plugins/how-to-send-email-in-wordpress-
using-the-gmail-smtp-server

I did want to have a @jasonhowe.net email address for those rare times when I may want to send someone an email that’s related to the site. This way they don’t get my personal gmail account address and it looks more professional.

I researched a bunch of free options and settled on Zoho.com. They have a “Forever Free” account that allows you to host up to 5 users for 1 domain, 25 MB attachment limit with web-based and app-based email access only (no POP/IMAP/SMTP) but I’m fine with that. I didn’t want to pay monthly for email for my hobby sites and didn’t want to get into the business of running my own email server (Dovecot or similar).

Secure Your Raspberry Pi and WordPress Sites

It’s important to secure your Raspberry and WordPress sites from hackers.

I followed this to secure the Raspberry Pi:

https://makezine.com/2017/09/07/secure-your-raspberry-pi-against-attackers/

Something that isn’t in that article but is worth mentioning, is to also enable multi-factor authentication (MFA) on your WordPress site. This requires you to input an additional code from your phone when logging in. This way, hackers still can’t get into your site if they get your credentials because they don’t have your phone to see the additional code that’s necessary to login. The code changes every 30 seconds.

I use this two-factor option and it works great:
https://wordpress.org/plugins/two-factor

Backup Your WordPress Site

It’s important to back up your WordPress site. The backups can be used in case data gets corrupted, hackers take the site over or when your SD card or Raspberry Pi dies (not if, but when).

I’m using the UpdraftPlus WordPress plugin to make backups to a Google Drive. It works great.

Other Considerations

Following the above has gotten me pretty much where I want to be. The only outstanding thing I’m mulling over is putting in a backup solution that backs up the entire contents of the Raspberry which can be used to restore to a new SD card or Pi when they die (again not if, but when). I’m gauging what’d be less work – get a backup solution in place that is secure, stable and easily monitored vs. needing to build a Raspberry Pi from scratch with the above config and then restoring the WordPress sites via the UpdraftPlus backups.

Leave a Reply

Your email address will not be published. Required fields are marked *