A project I’ve wanted to tackle for months was setting up WordPress on a Raspberry Pi, so that people could connect to it’s wifi network and access the installed WordPress site. I found a variety of helpful sites and wanted to document what worked for me as I expect software updates and small gaps and typos in instructions caused some real headaches.  It was a steep learning curve but that’s what the Raspberry Pi is all about right, learning.

This is my first project using a Raspberry Pi – so I’m a complete noob. I made a buttload of mistakes and followed instructions which I now recognise as being incorrect.  I guess these instructions may quickly get out of date as well with software updates, so be warned.

Step 1: Gather the Hardware and Software

Gather the Hardware

Firstly let me encourage you to purchase your equipment from a reputable seller. I have seen before in projects like this people seeking support when something in the software setup doesn’t work as expected and when it comes down to the fault it is with the equipment they’ve purchased.

Cheap alternate brand MicroSD cards and Raspberry Pi hardware may give you grief.  If you want to pay as cheap as you can find that’s OK – but you’ll get what you pay for. If it’s cheaper because it’s not checked properly by the manufacturer then just know what you’re getting may be risky.

The instructions you’re about to follow have been written using the recommended equipment and the sellers are who I purchased from.

Hardware List:

  • Raspberry Pi 3 Model B kit $42.99 (Canakit is a primary seller – kit includes Power supply) – buy on Amazon
  • Samsung 64GB EVO+MicroSD Card (buy a quality brand from a recognised dealer) – buy on Amazon
  • Case – Flirc case for Raspberry Pi (highly recommended by many) – buy on Amazon
  • ethernet cable – buy on Amazon

Hardware Setup:

These instructions are based on connecting your Raspberry Pi 3 to an HDMI monitor, mouse and keyboard. You will also attach your RPi to your modem/router using an ethernet cable so that it has an internet connection.

  1. To the RPi connect the keyboard, mouse and HDMI monitor
  2. Connect the ethernet cable to your modem/router
  3. Don’t connect the Power at this stage – youll notice the RPi doesn’t have a built-in On/Off switch, we will connect the Power once we have the Raspbian OS setup in the next stage.

Heres a photo of my setup (notice I’m using an HDMI adapter to connect to my monitor and in this photo I used a 3D printed case)


Gather the Software

Download and Install Raspbian OS

NOOBS is an easy operating system installer which contains the Raspbian operating system for your RPi. It also provides a selection of alternative operating systems which are then downloaded from the internet and installed – but we dont need any of that for this setup.  So we will download NOOBs then use that to install Raspbian.

Im using a Windows 10 laptop to do all the configurations and downloads – and writing the instructions down as I go – on a Mac I expect you can use Terminal, but Im not putting detailed instructions here.

  1. Download a zip file (around 1.5GB) of the latest image of NOOBs using the following link: https://www.raspberrypi.org/downloads/noobs/
  2. Now that you have downloaded the ZIP file of NOOBs you need to unzip/extract the contents and simply copy them to your MicroSD card
  3. Insert your MicroSD card to your computer (I just use the adapter and SD Card slot on the laptop)
  4. Format the MicroSD card as Fat32
  5. Copy all the files inside the uncompressed NOOBs folder to your MicroSD card
  6. Remove the MicroSD from your computer and insert into your Raspberry Pi, but don’t power it on quite yet.

In the Next Step we will configure the Raspbian OS on the Raspberry Pi.

Step 2: Configure the Raspberry Pi Operating System

Configure Raspbian OS on the Raspberry Pi

My hardware setup is using an external keyboard, mouse and monitor and is internet connected through an ethernet cable to my router. Im not sure how to get screenshots from Raspbian yet so am taking photos as I go for instructions. If anyone would like to contribute screenshots of the same thing please do.

So we have everything connected now except power – so lets fire it up by connecting the microUSB power cable.

You’ll see a Red light come on, then a Green one start flickering

On the monitor the screen will list a few OS that you can choose to install but we only want Raspbian [RECOMMENDED] so select that and click the Install button.

Confirm the install by clicking Yes

Sit back for a few minutes – maybe water the garden, have a beer – no wait till after …..
The Raspbian setup took 23 minutes with what I’ve got.


Once you get the success message click OK


The RPi will reboot and after a few seconds you will see the Raspbian desktop

Lets open the Terminal window and get things tweaked

This stage is just doing some housework setting up Raspbian on your RPi.

Opening the Terminal window you’ll see we are logged in already as the user – pi – and the host is called – raspberrypi (I’m going to change that later to Piweb) FYI the default password for pi is raspberry


OK lets get started – (below, the word sudo is used to run commands using the root user level of permission which the user pi doesn’t have. Ive since learned I could login as the root user and leave sudo out of the lines). After each line of code commands hit enter.

Download any available updates from the applications repository:
sudo apt-get update

Install those updates that have been downloaded (enter Y if prompted to continue)
sudo apt-get upgrade

Update the Rpi firmware
sudo rpi-update

Reboot the Rpi

Once she has rebooted, open the Terminal again…..

Give the user pi a new password

Enter old password (raspberry)
Enter your new password, then again

Give the user root a new password
sudo passwd
Enter your new password, then again

Login as root user
su       (then enter password for the root user)

(Login displayed will change to root@raspberrypi – see last line in the image above)

Make some tweaks to the Raspberry Pi configuration settings (this is also possible through the desktop GUI):

Network Options – Change the Hostname to “Piweb” (or whatever you want to call it – when entering into the web browser it will say for me – http://Piweb/)

Interfacing options – enable SSH (this will also help us setup SFTP later)

Finish – reboot

Next Step, we will start to install and configure the apps which will let our Raspberry Pi create its own wifi network.

Step 3: Create a wifi network on your Raspberry Pi

Create a Wifi Network on your Raspberry Pi

Ok I may use the wrong terms here, remember this is the first time I’ve done this so I’m learning myself. Correct me in the comments and I’ll update the instructions.

What we are doing now is installing hostapd and dnsmasq. Hostapd creates a wifi Access Point (AP) on our RPi wifi interface.

Dnsmasq from what I can workout is a combined DHCP and DNS server which enables the networking to take place – it allows people to join the wifi network then directs their traffic requests around the place.

Youll need to be internet connected so your RPi can download the application packages. Keep that ethernet cable connected to your modem/router.

Open Terminal (notice the change in hostname – @Piweb)

Im logged in as the user pi so will be using sudo before commands requiring a higher level of permission. You could login as root and leave out sudo, but Im not sure if there are any other issues doing that – Im new at this.

Install both hostapd and dnsmasq applications
sudo apt-get install hostapd dnsmasq

Before we start editing the configuration files we need to stop these two services from running
sudo systemctl stop dnsmasq

sudo systemctl stop hostapd

Specify an IP address for your Raspberry Pi by editing the dhcpcd.conf file (make sure you type correctly – typos will probably have you creating a new file)
sudo nano /etc/dhcpcd.conf

Scroll to the end of the file and add:
interface wlan0
static ip_address=

To finish editing the file press CNTRL X, Y, ENTER

At this point I noticed symbols like # I typed werent coming up correctly and discovered my Pi keyboard was configured for UK – change keyboard settings from the Raspbian desktop:
Preferences – Raspberry Pi configuration – Localisation – Set Keyboard – United States (type some symbols to confirm its set correctly)

Restart dhcpcd
sudo service dhcpcd restart

Edit the Hosts file to name our Raspberry Pi and give it an IP address
sudo nano /etc/hosts

Edit these lines in the /etc/hosts file localhost Piweb

So they read: localhost Piweb

Because that’s the IP address we specified for the wifi earlier…..
To save your changes to that file – Press CTRL X, Y, ENTER

Create a hostapd configuration file
sudo nano /etc/hostapd/hostapd.conf

Add these lines to the hostapd.conf file to create an open wifi network called FreeFiles on Channel 7:
interface=wlan0 #the name of the wifi interface
driver=nl80211 #the name of the driver
ssid=FreeFiles #the name of the wifi network we want created
channel=7 #the wifi channel to broadcast on

To finish editing press CNTRL X, Y, ENTER

Now we will edit the DNSMASQ config file, but the default one has loads of content. Instead of reading that and making modifications lets rename dnsmasq.conf to dnsmasq.conf.orig and create a new dnsmasq.conf file.

Rename the dnsmasq.conf file, and create a new one:
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf

Add the following text (my RPi is internet connected so I will comment out the 2nd line)
#comment out the next line if Rpi is internet connected so not all requests end up on your webserver

Adding that text means that when someone connects to the RPi they will be given an IP address between and and will get a 6 hour lease.

To finish editing press CNTRL X, Y, ENTER

The system needs to know where to find the new dnsmasq.conf configuration file, so we edit the hostapd file with it’s location:
sudo nano /etc/default/hostapd

Find the line #DAEMON_CONF=””, and replace it with:


Note you need to remove the # before DAEMON (otherwise it wont work)
To finish editing press CNTRL X, Y, ENTER

Then we can restart the network services
sudo service dhcpcd restart
sudo service hostapd start
sudo service dnsmasq start

Add routing and masquerade
sudo nano /etc/sysctl.conf

and uncomment this line to enable packet forwarding:

To finish editing press CNTRL X, Y, ENTER

Add a masquerade for outbound traffic on eth0:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Save the iptables rule:
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

sudo nano /etc/rc.local

and just above the last line “exit 0” add the line below to install these rules on boot.

iptables-restore < /etc/iptables.ipv4.nat

To finish editing press CNTRL X, Y, ENTER

OK so your Raspberry Pi is now configured to create a wifi access point and enable people to connect.

Reboot your RPi and see if your mobile device can see the wifi SSID we created – FreeFiles

After a RPi reboot I didn’t see the wifi SSID FreeFiles and discovered that I hadnt removed the hashtag from the line #DAEMON_CONF=”/etc/hostapd/hostapd.conf”:

Find the line #DAEMON_CONF=””, and replace it with:


So I made the edit, removing the #

I restarted the services:
sudo service dhcpcd restart
sudo service hostapd start
sudo service dnsmasq start

I rebooted the Rpi

On my iPhone located the SSID “FreeFiles”, connected successfully and heres the details from my Phone:

I opened Safari, and was able to browse to websites.


When I rebooted my monitor went full bizarre for some reason, all Red.

I took a photo, and while I did the monitor blinked and it came back as normal – not sure whats up…….. but it continues to do this sometimes starting Red but flicking back to normal after a couple of seconds.

Next we need to setup a webserver on our Raspberry Pi 3

Step 4: Setup a Webserver on Raspberry Pi 3

Now we can install the software required to deliver our website using our Raspberry Pi.

There are different webserver apps available and I’d just suggest reading around and making a choice as to which one to use. I chose to setup my webserver using apache2. The other one I considered was nginx (say “engine x”)

Install Apache2 on Raspberry Pi

Open a Terminal window

Download and install apache2
sudo apt-get install apache2 -y

Enable mod_rewrite
sudo a2enmod rewrite

Activate the new configuration
sudo systemctl restart apache2

We need to change one setting on Apache2 to allow .htaccess overrides in the /var/www directory, so open the apache2.conf file and change the AllowOverride None to AllowOverride All
sudo nano /etc/apache2/apache2.conf

Find the section:

<Directory /var/www/>

Options Indexes FollowSymLinks

AllowOverride None

Require all granted



And change      AllowOverride None     to          AllowOverride All

To finish editing the file press CTRL X, Y, ENTER

Restart apache2
sudo service apache2 restart

On any computer connected to your network, open a web browser and browse to the hostname of your Raspberry Pi – in my case Piweb

The default Apache will load:


You can also get there by entering the IP address your modem/router has given the RPi. To find out the IP addresses on your Raspberry Pi use the ifconfig command:

On the RPi in Terminal enter:

And look at the IP address given to the eth0 interface by your router. In my case –


Now we will install PHP
sudo apt-get install php libapache2-mod-php -y

Create a new PHP file to test php installed
cd /var/www/html

sudo nano index.php

Add the following lines to this new file (this will just create a page with heaps of PHP info on it):
<?php phpinfo();  ?>

To finish editing the file press CTRL X, Y, ENTER

Delete the default HTML file in the apache2 directory
sudo rm index.html

Restart Apache2
sudo service apache2 restart

Change the directory you’re from /var/www/html back to home

Go to your computers web browser again and browse to your hostname
(Mine – http://Piweb)


Install MYSQL

Mysql is the database engine which will run our WordPress database

Install MYSQL – (actually this seems to install MariaDB – not sure about what that means)
sudo apt-get install mysql-server php-mysql -y

If prompted for a root user password – provide one and note it down for your records – I wasnt prompted

Restart Apache2
sudo service apache2 restart

Install phpMyAdmin

In order to manage our MySQL databases, it’s far easier to use phpMyAdmin so let’s go ahead and install it by entering the following command, but note* you will be asked the following questions during the installation process:

Install phpmyadmin
sudo apt-get install phpmyadmin -y

At the prompts make the following changes:

  • Automatic Configuration = select apache2
  • Configure Database for phpmyadmin with dbconfig-common? – select Yes
  • Mysql application password for phpmyadmin:  provide a password (note this down somewhere)

Configure Apache for phpMyAdmin
sudo nano /etc/apache2/apache2.conf

At the end of the apache2.conf file add the following line:
include /etc/phpmyadmin/apache.conf

To finish editing the file press CTRL X, Y, ENTER

It bothered me that I wasnt prompted to setup a password for the root user, so did some research. Seems that that happens when you do a “secure installation”. So to play it safe I then did that:

Secure Installation
sudo mysql_secure_installation

Enter the current password for the root user = blank

Set root password = Y

Enter new password = [choose your own password]

Re-enter your new password

Remove anonymous user = Y

Disallow root login remotely – N

Remove test database and access to it – Y

Reload privileges table now? = Y


Create a mysql user
sudo mysql -u root -p

Enter the password for the MYSQL root user (created earlier) – [your password]

Enter the following command replacing username/password variables with your setup:
GRANT ALL PRIVILEGES ON mydb.* TO ‘username’@’localhost’ IDENTIFIED BY ‘password’;

For me it looks like this:

GRANT ALL PRIVILEGES ON mydb.* TO ‘pi’@’localhost’ IDENTIFIED BY ‘[my pi user password]’;

Exit the editor by typing \q:

Restart the apache2 service
sudo /etc/init.d/apache2 restart

Reboot the Rpi

In your web browser navigate to http://[your hostname]/phpmyadmin

for me this looks like =  http://Piweb/phpmyadmin


You can login as user phpmyadmin with the Mysql application password you gave earlier or as the user pi using your pi password.

Next stage – Setting up SFTP on your Raspberry Pi

Step 5: Setup SFTP on the Raspberry Pi 3

Accessing Files using SFTP

It’s really useful being able to access your Raspberry Pi using FTP, in this case SFTP. 
Make sure your Raspberry Pi is accessible using SSH – we did this earlier when configuring Raspbian.

Open your FTP software (I use Filezilla or WinSCP)

Use the following settings:

Host = Piweb (you use the Hostname you gave your Raspberry Pi earlier)

Port = 22

Protocol = SFTP – SSH File Transfer Protocol

Login Type = Normal

User = pi

Password = the password you set for your pi user

Then in the Advanced tab

Set the users default remote directory to /var/www


Ok next we install WordPress!

Step 6: Install WordPress on Raspberry Pi 3

Install WordPress on Raspberry Pi 3

Open Terminal again and login as root

Enter the password for the user root

Change to the directory where we want WordPress to live
cd /var/www/html

Delete any files in there (we created a single test one remember)
rm ./*

Now download the latest WordPress files to this location
wget https://wordpress.org/latest.tar.gz

Now extract the files and move them to the root directory (notice the “dot” after mv wordpress/* .   )
tar xvfz latest.tar.gz

mv wordpress/* .

Remove the compressed file
rm latest.tar.gz

Remove the empty wordpress folder
rmdir wordpress

Now when you browse to /var/www/html you will see all the WordPress files

Setup a WordPress Database and Database User

Now its time to create a MYSQL user and a database for your WordPress install.
Earlier we created a root MYSQL password, youll need that here.

Not the ; at the end of each command line when in MYSQL

Login to MYSQL as the root user
mysql -uroot -p[enter your password here with no brackets]

Create a MYSQL user called wordpressuser with the password warhammerrox (or whatever you choose)
create user 'wordpressuser'@'localhost' identified by 'warhammerrox';

Create a new database called mywordpress for the WordPress install
create database mywordpress;

Give the database user all privileges access to the database
grant all privileges on mywordpress.* to 'wordpressuser'@'localhost';

Not sure what this does…..
flush privileges;

Finish up by exiting


Install WordPress

In your web browser enter the URL to your host name and the WordPress installation page will appear.

Select your Preferred Language


The next screen lets you know what information WordPress requires for setup:


Enter the details asked for – we have the info from our earlier setup



Give Your WordPress site a title, user and password


You’ll get a confirmation page once everything has setup:


Youre in business, now you can configure WordPress how you like.


Accessing your site now – connect to your Raspberry Pi wifi network = FreeFiles, then in your web browser navigate to http://[yourhostname]/ and the WordPress site will load. http://localhost/ will also work, as will http://[your RPi IP address].

If your RPi is connected to the internet (by ethernet to your internet connected router) people will be able to also share that internet connection and browse to whatever online services they want to.

Next I am going to setup a Captive Portal using nodogsplash so that when someone connects to the RPi wifi network thay are directed only to my locally hosted WordPress site and wont have internet access. Different devices treat captive portals in different ways so it seems a little messy. Still let’s give it a crack.


Step 7: Setup Samba for easy file access on the Raspberry Pi 3

Having Samba setup on your Raspberry Pi makes it nice and simple to access files using Windows or OSX computers on your network using the SMB protocol.

Open a terminal window

Install Samba and Samba common
sudo apt-get install samba samba-common-bin

Edit the Samba smb.conf file to change your Samba settings
sudo nano /etc/samba/smb.conf

Find the line containing – wins support – and if there is a hashtag # at the beginning of the line remove it to uncomment the text before changing the value to Yes, set your_workgroup_name to your local workgroup (usually the default, “Workgroup”)
workgroup = your_workgroup_name
wins support = yes

Add the following lines to the section called Share Definitions, the path line specifies the share path on your Raspberry Pi and can be modified to the level you want. The setting below just makes all areas available.

comment= Pi Home
only guest=no
create mask=0777
directory mask=0777

Save your changes to the smb.conf file by pressing CTRL X, Y, ENTER

Now you need to set the password for samba using the following command:
sudo smbpasswd -a pi

choose and enter a password

Restart samba with the following command and your new Raspberry Pi share should appear on your Windows or OSX network.
sudo /etc/init.d/samba restart