Install a complete WordPress host in a Raspberry Pi


Last Updated on 17th March 2022 by peppe8o

Creting a personal blog can give a lot of satisfaction for all, but not all the time you can have enough money to afford the very first costs. With WordPress on Raspberry PI you can start with the cost of a cheap boar

When I received my first Raspberry PI Model A+, I was excited to test it by building up my home-made new WordPress host on it. And started its very first days from an RPI hosting at home.

You can also create your own blog starting with a cheap investment. In order to reach and publish your website on Internet, you will also need:

  • You will need a public IP from your provider and a domain name (also dynamic domain names are good)
  • Also to be able to setup your local network to forward ports 80 (for http) and 443 (for https)

My NoIP guide can be helpful also for this stuff.

This tutorial will provide a step-by-step guide to installing a complete WordPress host in a Raspberry Pi. Even if it is created on Raspberry PI 3 Model A+, the same procedure applies also to other Raspberry PI computer boards.

What we need

As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if to continue with the project or remove them from the shopping cart. So, hardware will be only:

Check hardware prices with the following links:

Amazon raspberry pi boards box
Amazon Micro SD box

Step by step guide

Prepare Operating System

First of all, we’ll install Raspberry PI OS Lite. Make sure that your OS is up to date. From your terminal, please issue the following command:

sudo apt update -y && sudo apt upgrade -y

Next step is installing the so-called LAMP stack (Linux + Apache + MariaDB + PHP). For this task, you can use my LAMP server on Raspberry PI tutorial.

Now let’s face the required packages. WordPress requires the following PHP extensions:

  • json: MANDATORY
  • mysql: MANDATORY (alread installed following my LAMP tutorial)
  • curl > we’ll install it
  • dom: included in php-xml > we’ll install it
  • exif: already included in php-common
  • php-fileinfo: already included in php-common
  • hash: already included in RPI OS
  • imagick > we’ll install it
  • mbstring > we’ll install it
  • openssl: already included in RPI OS
  • pcre: not located in apt
  • xml > we’ll install it
  • zip > we’ll install it

Moreover, the following PHP extensions can be helpful in some cases:

  • bcmath > we’ll install it
  • filter: not located in apt
  • gd > we’ll install it
  • iconv: already included in php-common
  • intl > we’ll install it
  • mcrypt > we’ll install it
  • simplexml: already included in php-xml
  • sodium: not located in apt
  • xmlreader: already included in php-xml
  • zlib: not located in apt

You can install all the missing PHP extensions with the following command:

sudo apt install php-json php-curl php-imagick php-mbstring php-xml php-zip php-bcmath php-gd php-intl mcrypt -y

After these installations please restart Apache Web server:

sudo systemctl restart apache2

Installing WordPress

Download the latest WordPress version:


extract the zip archive

sudo unzip

move the extracted directory (“wordpress”) and all its content to Apache web root (replace with your real domain name)

sudo mv wordpress/ /var/www/

Configure MariaDB for your WordPress Site

Log into MariaDB shell as root

sudo mariadb -u root

create a database for WordPress (I called it wordpress, but you can name it as you prefer):

create database wordpress;

grant all privileges of WordPress database to the user that you will configure in WordPress in next steps:

grant all privileges on wordpress.* to wpuser@localhost identified by 'your-password';

Flush the privileges table for the changes to take effect and then exit

flush privileges;

Configure WordPress

Go to your WordPress directory and copy the sample configuration file

cd /var/www/
sudo cp wp-config-sample.php wp-config.php

edit the new config file

sudo nano wp-config.php

Find the following lines and replace the red texts with the database name, username and password you created in the previous step (Configure MariaDB for your WordPress Site).

/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

Save and close the file.
Set the Apache user (www-data) as the owner of the WordPress site directory:

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

Create an Apache Virtual Host file for WordPress (change “” with your domain name)

Create a virtual host file for your WordPress site

sudo nano /etc/apache2/sites-available/

Paste the following text into the file:

<VirtualHost *:80> 
  DocumentRoot /var/www/
  #This enables .htaccess file, which is needed for WordPress Permalink to work. 
  <Directory "/var/www/">
    AllowOverride All
  ErrorLog ${APACHE_LOG_DIR}/
  CustomLog ${APACHE_LOG_DIR}/ combined

Save and close.

Save and close the file. Test configurations:

sudo apache2ctl configtest

If you see “Syntax OK” (even if after the “Could not reliably determine the server’s fully qualified domain name” warning), then enable rewrite and the virtual host, reload Apache for the changes to take effects:

sudo a2enmod rewrite
sudo a2ensite
sudo systemctl reload apache2.service

Now we can start the WordPress Wizard setup in our browser.

Here you must set port forwarding rules in your home router (at least for ports 80 and 443). But you can also test your installation by making your local PC aware that (or the domain we set in previous steps) link to our raspberry. For this reason, once known our raspberry local IP, you can set our host file redirecting to it. You can find the hosts file in:

  • C:\Windows\System32\drivers\etc\hosts for windows-based PC
  • /etc/hosts for linux based PC

by adding (via notepad) the following row to the end (please change <<Your.Raspberry.IP.Here>> with the IP address of your raspberry):


Finally, you can launch the final WordPress wizard: browse “”. The wizard will ask you to select your language:

wordpress installation language

Select your one and press “Continue”. The following page will require you to set:

  • Site title
  • WordPress administration user
  • WordPress administration password
  • WordPress administration email
wordpress installation admin credentials

Again, set it according to your preferences and click the “Install WordPress ” button. A final page will confirm the successful installation:

wordpress installation complete confirm

Use the “Log in” button to go to the login page:

wordpress login page

Use the admin credentials above defined to enter your WordPress dashboard:

wordpress dashboard

What’s Next

Interested in more cool ways to use your RPI? Take a look at peppe8o Raspberry PI computer tutorials!


How useful was this post?

Click on a star to rate it anonymously!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?