Some links in this post may be affiliate links. We may get paid if you buy something or take an action after clicking one of these, but without addictional costs for you compared to direct buying.

Install a complete WordPress host in a Raspberry Pi

Raspberry PI Wordpress featured image

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. In order to reach and publish your website to 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 these stuff.

This tutorial will provide a step-by-step guide to install 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 models.

What we need

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

Check hardware prices with following links:

Amazon raspberry pi boards box
Amazon Micro SD box

Step by step guide

First of all, we’ll install Raspberry PI OS Lite.

Next step is installing the so called LAMP stack (Linux + Apache + MariaDB + PHP).

Updating our version

This step is always suggested before every installation:

sudo apt update && sudo apt upgrade

Installing Apache

This step is quite simple. We’ll install also apache2-utils, which include some useful tools:

sudo apt install apache2 apache2-utils

After it’s installed, we can check Apache status:

systemctl status apache2

and you shoul see the folowing:

● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-11-28 21:07:39 GMT; 12s ago
Main PID: 14961 (apache2)
CGroup: /system.slice/apache2.service
├─14961 /usr/sbin/apache2 -k start
├─14962 /usr/sbin/apache2 -k start
└─14963 /usr/sbin/apache2 -k start

Enable Apache to start on boot:

sudo systemctl enable apache2

Finally set www-data as user and group assigned to root document:

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

Installing MariaDB

Now let’s go on installing our Database:

sudo apt install mariadb-server mariadb-client

After it’s installed, systemctl to check MariaDB status:

systemctl status mariadb.service

and you should see the following:

● mariadb.service - MariaDB 10.1.37 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-11-28 21:19:02 GMT; 1min 0s ago
Docs: man:mysqld(8)
Main PID: 16727 (mysqld)
Status: "Taking your SQL requests now..."
CGroup: /system.slice/mariadb.service
└─16727 /usr/sbin/mysqld

enable MariaDB to automatically start at boot

sudo systemctl enable mariadb.service

Now run the post installation security script:

sudo mysql_secure_installation

answering yes to the following questions in order to enhance security in your database.

Installing PHP

Last step to complete our LAMP server is related to PHP:

sudo apt install php7.3 libapache2-mod-php7.3 php7.3-mysql php-common php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-readline php7.3-mbstring php7.3-xml php7.3-mysql php7.3-common php7.3-gd php7.3-json php7.3-cli php7.3-curl

Enable the Apache php7.0 module then restart Apache Web server.

sudo a2enmod php7.3
sudo systemctl restart apache2

Installing WordPress

Download latets WordPress version:


extract the zip archive

sudo unzip

move the extracted directory (“wordpress”) and all its content to Apache web root (replace with you 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 the file. Test configurations

sudo apache2ctl configtest

If you see “Syntax OK”, then enable this virtual host and reload Apache for the changes to take effects

sudo a2ensite
sudo systemctl reload apache2.service

Now we can start WordPress Wizard setup in our browser. But, first, we need to make our 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, we must set our host file redirecting to it. Hosts file can be found 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 finalization WordPress wizard: browse “”.

You will be required to set:

  • Site title
  • WordPress administration user
  • WordPress administration password

click Install WordPress button … et voilà, your host is ready and working!


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?

Leave a Reply

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

I accept the Privacy Policy