Install WordPress on a Raspberry Pi 3 or higher + troubleshooting

For this article, I assume you know Raspberry pi basics. I will not go over these here.

Before we begin, I used Raspbian Lite. I expect that SSH is enabled and that you verified that all software is up-to-date. If that is the case, we can continue.

SSH into your Raspberry pi

Install Apache web server

Us the following command to install Apache2: sudo apt-get install apache2 -y

If everything went fine, you can surf to the Pi’s IP address in your browser and you’ll see something like this:

With Apache2 installed, it’s time to install PHP.

Install PHP

To install PHP and all required packages, type:

sudo apt install php7.3 php7.3-mbstring php7.3-mysql php7.3-curl php7.3-gd php7.3-zip php7.3-xm .3-imagick -y

Once all of these are installed, restart Apache with:sudo service apache2 restart

Install MySQL

In order to run WordPress we will need a database, for this we will be using MariaDB. To install MySQL, use the following command: sudo apt install mariadb-server

Make sure to restart Apache after you’ve installed MySQL: sudo service apache2 restart

That’s it! The Raspberry pi is now ready to install WordPress!

Download WordPress

In order to install WordPress, first go to the Apache ‘html’ folder and make sure that everything that’s still in there (like the default page) is erased so that we can start with a clean slate. Simply: cd /var/www/html/

And now type the following command in order to delete everything that’s in the ‘html’ folder: sudo rm *

With the ‘html’ folder empty, it’s time to download WordPress: sudo wget

Once the ‘latest.tar.gz’ file has been downloaded, you can unzip it: sudo tar xzf latest.tar.gz

This will have created a folder named ‘wordpress’ in the ‘html’ folder. Next, copy all the contents of the ‘wordpress’ folder into the ‘html’ folder.

sudo mv wordpress/* .

Now that all the WordPress files arena the ‘html’ folder, continue by deleting the ‘wordpress’ folder and the ‘latest.tar.gz’.

sudo rm -rf wordpress latest.tar.gz

Let’s add the ‘html’ folder and all subfolders to the www-data group: sudo chown -R www-data: .

Set up MySQL / MariaDB

Before we can create a WordPress database, we need to setup MySQL/MariaDB first. To do so, type: sudo mysql_secure_installation

You will be prompted with a series of questions, lets go through them together:

First it will ask: Enter current password for root (enter for none): as we have not yet set a root password, simply type Enter.

Next it will ask you: Set root password? Type y.

Type a password for: New password: followed with Return. It is very important that you remember this password as we’ll need it later to install WordPress.

Typ y for all of the following : Remove anonymous users, Disallow root login remotely, Remove test database and access to it and Reload privilege tables now.

When all steps are done MariaDB will tell you All done! and Thanks for using MariaDB!.

Create the WordPress database

Typ: sudo mysql -uroot -p

Followed by: create database wordpress; in order to create a database named ‘wordpress’.

In this step, it is very important to replace CHOSENPASSWORD with the password you used for the root user in the setup of MySQL / MariaDB.


with that done, flush all the privileges with: FLUSH PRIVILEGES;

Now you can exit MariaDB with ctrl + d.

WordPress configuration

Now open your browser again and surf to the IP address of your Raspberry pi. You should see a WordPress page asking you to choose a language. Choose your language and click Continue. Next you get a welcome screen. Click the Let’s Go! button. In the next window enter all the information of the database we just created. It should look something like this:

Database Name: wordpress
User Name: root
Database Host: localhost
Table Prefix: wp_

Click Submit to continue. Next click on Run Install to finish installation.

That’s it, you’ve successfully installed WordPress on your Raspberry Pi. One of the things I can only recommend is to work with friendly links:

Friendly links

It’s important to change the permalink settings to make your URLs easier.
To do so, log onto your site and go to the Dashboard. Go to Settings, Permalinks and select Blogpost. Now click on Save changes.

Using SSH type the following command: sudo a2enmod rewrite followed with: sudo nano /etc/apache2/sites-available/000-default.conf. In this file, add the following:

<Directory "/var/www/html">
AllowOverride All

Make sure that together with the <VirtualHost *:80>, the file looks like this:

<VirtualHost *:80>
    <Directory "/var/www/html">
        AllowOverride All 

Exit the editor by typing ctrl + x and safe with y.

Restart Apache with: sudo service apache2 restart


I encountered a few issues when installing WordPress on my Raspberry pi. Luckily the ones I encountered are easy to fix.

File exceeds the upload_max_filesize

You can encounter this error when uploading themes or files. The easiest way to fix this is by editing the ‘php.ini’ file. To do so SSH into your pi and type: sudo nano /etc/php/7.3/apache2/php.ini.

Once in the nano editor, change or add the following rules:

memory_limit = 256M 
upload_max_size = 64M 
post_max_size = 64M 
upload_max_filesize = 64M 
max_execution_time = 300 
max_input_time = 1000

It’s not always easy to find them in the vast file. You can search the file with ctrl + w. When you made the changes exit the editor by pressing ctrl + x and type y to save it.

Reboot the pi.

The REST API encountered an error
Your site could not complete a loopback request

This error might also present itself as:
Error: cURL error 28: Resolving timed out after 10000 milliseconds (http_request_failed)

SSH into the pi and type: sudo nano /etc/dhcpcd.conf and add the following DNS server: static domain_name_servers=

Exit the editor with ctrl+x and save with y.

Reboot the pi.

Leave a Reply

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