If you want the easiest and most user-friendly WordPress experience, a managed host like WP Engine that does all the setup and maintenance so you can focus on your content. This is what we use to run our own sister sites.
But if you don’t have the funds or just want to improve your DIY skills, then you can use a Raspberry Pi for your WordPress site.
Below is how to set up Apache, MySQL and PHP on Raspberry Pi and host websites both locally and online.
Why Use WordPress?
If you are looking for a way to host a website with minimal effort, WordPress is not the obvious solution. We’ve already covered how to set up your Raspberry Pi to host a static or dynamic website (that is, one that uses standard, pre-written pages, or one that uses a database to populate pages).
But if you really need to use WordPress, or you’re developing a theme or plugins for a WordPress site, then a Raspberry Pi with a blogging platform installed and ready to use is a great option.
Which Raspberry Pi Should You Use?
To install WordPress on your Raspberry Pi, you need to set it up as a LAMP server. Once Linux, Apache, MySQL, and PHP are installed, your Pi will be able to run WordPress (and other site software).
Several Raspberry Pi models are available. You may have one, several, or none. But which one is the most suitable for running WordPress?
Luckily, any version of the Raspberry Pi can be used to host a WordPress site. However, for best results, we recommend using a Raspberry Pi 2 or later. Also, make sure you’re using a large SD card — at least 16GB — as storage space is a key requirement for web servers. (Also consider some external storage for the Pi!)
The rest of this guide assumes that the Raspberry Pi is turned on and connected to the local network. You must also have SSH configured for remote command line access.
Step 1: Set up the Apache web server
Start by installing the Apache web server. This is software that allows you to serve any type of web page in any browser. That’s all you need to serve up an HTML page, whether statically or dynamically generated with PHP.
sudo apt install apache2 -y
Once installed, Apache will place a test HTML file in the web folder on your Pi. You must check this from another computer (or smartphone) on your network. You will need to enter the Pi’s IP address in the address bar of your browser. If you are using SSH, you already know this; otherwise, enter:
hostname -I
This displays the IP address of your Raspberry Pi. The page you see should look something like this:
You can also test the webpage from your Raspberry Pi at http://localhost.
Step 2: Install PHP on Raspberry Pi
Next, it’s time to install PHP. It is a software preprocessor that allows you to serve server-generated web pages rather than static HTML pages. Although the HTML page can be written in its entirety, the PHP page will contain calls to other pages and to the database to populate it with content.
While other server platforms are available (such as ASP), PHP is important here as it is required by WordPress since WordPress itself is written in PHP.
Install with:
sudo apt install php -y
Once this is done, you should check that PHP is working. Change directory to /var/www/html/ in the following way:
cd /var/www/html/
Delete file here index.html (the web page you were viewing earlier):
sudo rm index.html
Then create a new file named index.php (nano is installed by default):
sudo nano index.php
Here, add any (or all) of the following code:
In order, these commands display:
- Phrase «Hello World»
- Current date and time
- PHP information for installation
Save the file, then restart Apache:
sudo service apache2 restart
Refresh the page to see the results.
PHP and Apache both work. Now it’s time to install the MySQL database software.