Setting Up WordPress on a Raspberry Pi 4

I’ll go over the steps and resources I used in setting up WordPress on a Raspberry Pi 4. This is not a step-by-step guide in itself, but many of the links are and I think I covered everything that I did in the general order that I did them.

I switched from hosting my site with WordPress on a personal tier to instead use a Raspberry Pi server at my home. Why?

Since my site will never be all that busy and my home Internet is fast enough both up and down to host a simple website, why not host it myself and play around with a Raspberry Pi at the same time? I will also be able to use some add-ons that would otherwise require me to upgrade to a business account with WordPress.

Thought Process

I had a spare static IP address and a site hosted via WordPress. There are too many limitations in a basic personal WordPress hosted site and I wanted more control over the content so I could learn WordPress for my job.

Okay sure, I’m adding a domain name that adds cost. It was about $40 for two years and will be $18 each year thereafter. That alone is less than what I was paying WordPress. I’m also buying a Raspberry Pi 4 kit so that is an added cost.

However, I’m getting rid of a yearly WordPress hosting cost and adding in new features like my own domain and the ability to use custom CSS and plugins that right now would require me to upgrade to a WordPress business tier. In about a year I’ll start saving money.

How did I do it?

Setting up WordPress on a Raspberry Pi 4 was surprisingly easy. The following lists various resources in creating a WordPress site on a Raspberry Pi 4. If you have everything in place you could probably do it in less than an hour. It took me a couple of days. Oh yeah, I document things to remind me how I did something. That is the main purpose for many of my posts.

Let me preface this by saying that at the beginning of this process I started out with a static IP already set up on my AT&T modem. I cannot describe the process of getting that other than to say the AT&T tech handled it when I bought it in a pack of 5 to set up a work VPN.

1) Raspberry Pi

Obviously, first you need a Raspberry Pi (4). I went with a CanaKit to get everything I needed to get the Raspberry Pi going. As far as operating system goes, I chose Raspberry Pi OS (32-bit) and installed on an SD using Raspberry Pi Imager.

The CanaKit is well put together for a machine that won’t be running anything resource intensive. It has no screws, you just snap it together. The SD card tested as well as the fastest SanDisk I could find and all of the other accessories were used when building the Raspberry Pi.

If you want to do anything that will typically lead to overheating, go with another kit that lets you use a larger heatsink. There isn’t any room to do that here, but for my purposes this kit is fine.

In playing around on YouTube, 1080P video was very laggy. Again, this will be a web server, I’m not going to watch YouTube videos on it. This issue is common with Raspberry Pi OS and other Linux distros, some reportedly work just fine but I have yet to try them. WebOS may be a good fit if that is your goal.

Click here to view on Amazon: CanaKit Raspberry Pi 4 8GB Extreme Kit – 128GB Edition (8GB RAM)

2) Export current WordPress

The first step to getting WordPress set up was to go on to my current WordPress site and export everything. Login and go to the admin console. Go to Tools and then the Export sub menu. From there choose Export all. You’ll end up with a zip file or xml you can store away for later Import to the new site. If you don’t already have a WordPress site, then clearly that’s not something you need to worry about. You’ll be starting fresh.

3) Create the new WordPress site on the Raspberry Pi

Build a LAMP web server with WordPress, that is to say a Linux, Apache, MySQL, PHP server with WordPress installed. Raspberry Pi OS is a Linux distribution. Worried about Linux? Don’t be.

4) Configure the static IP address

Setup a Raspberry Pi Static IP Address

5) Set up the domain on the Raspberry Pi

Use a Domain Name with a Raspberry Pi Web Server

6) Map static IP address to Raspberry Pi

I have a home connection with AT&T fiber. While my modem already knows about my static IP addresses, I need to map one to the raspberry pi, yes the same one associated with my domain. Go to the modem and choose the Home Network tab. Choose the IP Allocation tab. We need to map an address to a device. Your raspberry pi should show in the IPv4 Address/Name column. Choose Allocate and at the bottom there is a New Allocation selection box. Choose a public fixed IP address to allocate for this connection. If you mess up it can take some time for you to switch between different IPs.

7) Fix WordPress due to change in IP address or Domain

WordPress is stupid, in that it hard codes URLs. You have to fix these by connecting to MySQL and updating via replace commands the old URL with the new URL.

Change and Update WordPress URLS in Database When Site is Moved to new Host

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

8) Secure your Raspberry Pi

Securing your raspberry pi, change the pi account and disable services, including SSH, when not in use. You may not be able to remove the pi account entirely, but its always good to change anything that was created by default by the operating system.

9) Let the outside world in

Let traffic in through your firewall. I had everything seemingly working. I even tested it on my phone, but what I didn’t consider is my Wi-Fi is going through the same AT&T router as the static IP I set up. In reality, the outside world could not see it. If you are like me and have AT&T fiber, then go to the modem and choose Firewall, enter your device ID, and in Public Subnet Hosts add a Public Subnet Rule Entry for your public IP address (which is already set up on this modem. You can limit it to Port Range of 80. Choose Protocol TCP and put 80 in the top and bottom range boxes and press Add. I don’t have a secure site and no other traffic needs to make it through, so port 80 it is.

10) Secure unused networks

Disable Wi-Fi, not using it so it shouldn’t be available.

Future steps

This next step I haven’t done yet. I want to have a larger and faster hard drive so I’ll boot from USB. I don’t want to go through the steps above all over again so I’ll copy what I have over to the new drive as is.


That wasn’t horrible, setting up WordPress on a Raspberry Pi 4 is doable and a good deal of what was done above can be skipped if you just want something to test locally. But wait, I’m telling everyone how this server is set up? That’s a security concern right?

There is nothing on this server that I care about. It is alone on its own network with no access to any other machine. I have a backup of the original SD. I’ll also do regular exports so I can do it all again. Hell, its not all that hard to guess most machines out there are on Linux. Still, it is true that the less you say, the better.

Leave a Reply

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