Install a WordPress site on Raspberry with Apache

Material needed :
– A Raspberry Pi + power cable + micro SD card
– Network connection
– Computer

1. Enabling SSH connection

With the PC & a micro SD card reader : The connection can be enabled by creating a file named ‘ssh’, without extension. It should be placed in the folder ‘boot’.

With a PC, HDMI cable, keyboard, computer mouse : Connect the Raspberry with the equipment and in the Terminal : sudo raspi-config
3 Interface Options > I2 SSH > Yes

2. Install Apache
sudo apt install apache2

3. Install PHP
sudo apt install php

4. Install Database : MariaDB
sudo apt-get install mariadb-server
sudo mysql -u root

Create a user : CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
Create the database which will be used by the website : CREATE DATABASE database_name;
Give the permissions of the new user on this database : GRANT ALL ON database_name.* TO 'username'@'localhost';

5. Allow PHP to connect to the database
sudo apt install php-mysql

6. Restart Apache
sudo service apache2 restart

7. Install WordPress
sudo wget https://wordpress.org/latest.zip -O /var/www/html/wordpress.zip
cd /var/www/html
sudo unzip wordpress.zip
sudo chmod 755 wordpress -R
sudo chown www-data wordpress -R

All the files after the unzip will be placed in a folder named ‘wordpress’, replace all the content in /var/www/html with the command sudo mv wordpress_content /var/www/html.

8. Configure WordPress
The database username, username, password, database host and table prefix should be the same than the one during the configuration. Then it just lasts the website’s configuration.

Note : The access to the administration is made with website_url/wp-admin