fbpx

Most orders for IN STOCK items placed by 12PM CST M-F ship SAME DAY. Orders for custom items and prints may take additional time to process.

Setting up WordPress on a Raspberry Pi

If you followed our previous article about configuring a Raspberry Pi as a web server, then you’re going to love this article. We’re going to go through the process of setting up WordPress on a Raspberry Pi. You’ll be able to make your Pi into a full personal blogging appliance.

Project Parts List

In case you’re not already setup with a Raspberry Pi and you’d like to acquire the materials for this project, we’ve provided this simple parts list for this project:

Setting up WordPress on a Raspberry Pi

At first you might be wondering why anyone would want to run WordPress on a Raspberry Pi. Your WordPress Pi is more than capable of running a small personal blog, a home family website, or even as a home automation controller! And since the Raspberry Pi has GPIO it opens a world of possibilities for WordPress pages to control things in the physical world, or to receive input. One such great project is a Raspberry Pi weather station that feeds data to a WordPress page!

To install WordPress, we first need to setup the Raspberry Pi as a LAMP server (technically RAMP although Raspbian is still Linux based). LAMP is short for Linux, Apache, MySQL, PHP.  All of these components are needed to run WordPress.

Preparing Raspberry Pi Lamp Services

I’d like to point out before we begin that almost every error we see setting up WordPress on a Raspberry Pi is related to running an old outdated version of Raspbian. We highly recommend you re-image your Micro-SD card before moving on to the next steps.

Step 1: Boot your Raspberry Pi and open a terminal window. Make sure all of the latest patches are installed and apt is up to date.

sudo apt-get update
sudo apt-get upgrade

Step 2: Install the Apache web server software.  This is the actual server software which will allow your Raspberry Pi to serve web pages to other devices.

 sudo apt-get install apache2 -y 

Step 3: Install PHP.  This is the software that will allow your Pi web server to execute scripts and process code.

sudo apt-get install php7.0 libapache2-mod-php7.0 -y

Step 4: Now it is time to install MySQL, the database that will store all of the information in your WordPress site.  The first command installs the MySQL server while the second command will secure the installation and create your root account and password.

sudo apt-get install mysql-server php7.0-mysql -y
sudo mysql_secure_installation

Step 5: Change to the html directory of your web server and remove the existing contents.

cd /var/www/html
sudo chown pi: .
rm *

Step 6: Download and extract the latest version of WordPress.

wget http://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz
mv wordpress/* ./
rm -rf wordpress latest.tar.gz
rm -rf index.html

Step 7: Change ownership of all of the WordPress files to the www-data service account.

 sudo chown -R -f www-data:www-data /var/www/html 

Step 8: At this point we highly recommend a reboot of your Raspberry Pi to bring things into a clean state.

sudo reboot

Step 9: Now that everything is installed we will need to set up a database to connect to.  Use the MySQL command to log in, use the –p flag for the password and –u for the username. Do NOT use a space between the flag and text.

sudo mysql -uroot -ppassword_you_chose_in_step_4
create database wordpress;

If you typed everything correctly you should she the response Query OK, 1 row affected (0.00).

Step 10: Create a MySQL service account for WordPress to use and grant it full permissions on your WordPress database.

GRANT ALL PRIVILEGES ON wordpress.* TO 'your_service_account_name'@'localhost' IDENTIFIED BY 'your_new_password';

And now press CTRL-D to exit the MySQL command line administrator.

Step 11: In a web browsers on another computer, browse to the IP address of your Raspberry Pi.  You will be greeted by the WordPress initial configuration screen.  You’ll need to setup the following configurations:

  • Database Name: wordpress
  • User Name: username you chose in step 10.
  • Password: password you chose in step 10.
  • Database Host: localhost
  • Table Prefix: wp_

Once you’ve entered the information, click ‘submit’ and you’ll be greeted with the initial WordPress site configuration page where you can configure your admin account, password, and the name of your WordPress blog!

Enter the details and click ‘Install WordPress’.  Your job is done!  You know have a Raspberry Pi WordPress server!  Feel free to leave comments or suggestions below!


Upgrade to Premium

If you like our content maybe consider upgrading to Premium. You’ll get access to

  • Free access to all plans
  • Member only videos
  • Early access to content
  • Ad free Experience
  • Discounts on store merch
  • Direct hotline contact form

One Response

Leave a Reply