WordPress on Raspberry Pi

Raspberry Pi with LAMP installed
Raspberry Pi with LAMP installed

Is it possible to run an existing WordPress site on a raspberry Pi?  Theoretically yes since we have Apache, PHP and MySQL working under Raspbian. This goes under the term of LAMP (Linux, Apache, MySQL or MariaSQL, PHP) As you can see above, it is possible and works quite well.


  • Install raspbian via NOOBS on a 32GB SD card, see my other post
  • Install some required Software
  • Setup Database
  • Copy files
  • Configure Software

Install some required Software

First we run the terminal program
As always, we update the current installation
$ sudo apt update
# lets upgrade to the latest patches
$ sudo apt upgrade
# lets install the latest Firmware
$ sudo rpi-update

Now we install the 3 requirements for WordPress
$ sudo apt install apache2 -y
# lets install php
$ sudo apt install php -y
#lets install the database
$ sudo apt install mysql-server php-mysql -y

Setup the Database (DB)

$sudo mysql -uroot -p
>create database mydatabase;
>create user mydatabase identified by ‘secretpassword’;
>grant all privileges on mydatabase.* to ‘mydatabase’@localhost identified by ‘secretpassword’;
>flush privileges;

Backup and Import DB:
First create a backup of your current site and copy the sql file to /home/pi/Desktop
$ cd ~/Desktop
$ sudo mysql -umydatabase -p mydatabase < mydatabase.sql

Make your installation more secure:
$ sudo mysql_secure_installation
$ sudo a2enmod rewrite

Minor modifications to the DB

Get hostname, meaning the IP address:
$ sudo hostname -I
–> (I got

$ sudo mysql -uroot -p
>use mydatabase;
>select * from wp_options where option_name=’siteurl’ or option_name=’home’;
>update wp_options set option_value=’′ where option_name=’home’;
>update wp_options set option_value=’′ where option_name=’siteurl’;

Lets restart the DB and webserver:
$ sudo service mariadb restart
$ sudo service apache2 restart

Copy Files

Lets copy all files from your existing WP installation to /home/pi/Desktop/temp (depending on the size, this can take a couple of hrs)
$ cd /var/www/html
$ sudo rm -rf *
$ cd ~/Desktop/temp
$ sudo mv * /var/www/html
$ cd /var/www/html
$ sudo mkdir tmp (in order to upgrade your installation later, in config file)
$ sudo chown -R www-data: .

Configure Software

In case you have the Google Recaptcha plugin, we need to disable it: (in order to login to admin pages)
$ cd /var/www/html/wp-content/plugins
$ sudo mv google-captcha google-captcha-old

Lets modify the webservers config file, I use geany as an editor. If you don’t have Geany installed, just install it.
$ sudo apt install geany
$ cd /etc/apache2/sites-available
$ sudo geany 000-default.conf
(after line 1)
<Directory “/var/www/html”>
AllowOverride All
(save and exit)

Now restart the DB and webserver again:
$ sudo service mariadb restart
$ sudo service apache2 restart

Test it

launch chromium an test your setup

Login to your site:

Print Friendly, PDF & Email