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 peppe8o.com 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:
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.
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:
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:
Moreover, the following PHP extensions can be helpful in some cases:
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
Download the latest WordPress version:
wget https://wordpress.org/latest.zip
extract the zip archive
sudo unzip latest.zip
move the extracted directory (“wordpress”) and all its content to Apache web root (replace example.com with your real domain name)
sudo mv wordpress/ /var/www/example.com
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;
exit;
Go to your WordPress directory and copy the sample configuration file
cd /var/www/example.com/
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/example.com/ -R
Create a virtual host file for your WordPress site
sudo nano /etc/apache2/sites-available/example.com.conf
Paste the following text into the file:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
#This enables .htaccess file, which is needed for WordPress Permalink to work.
<Directory "/var/www/example.com">
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/example.com.error.log
CustomLog ${APACHE_LOG_DIR}/example.com.access.log combined
</VirtualHost>
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 example.com.conf
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 example.com (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:
by adding (via notepad) the following row to the end (please change <<Your.Raspberry.IP.Here>> with the IP address of your raspberry):
<<Your.Raspberry.IP.Here>> example.com
Finally, you can launch the final WordPress wizard: browse “http://example.com/wp-admin/install.php”. The wizard will ask you to select your language:
Select your one and press “Continue”. The following page will require you to set:
Again, set it according to your preferences and click the “Install WordPress ” button. A final page will confirm the successful installation:
Use the “Log in” button to go to the login page:
Use the admin credentials above defined to enter your WordPress dashboard:
Interested in more cool ways to use your RPI? Take a look at peppe8o Raspberry PI computer tutorials!
Enjoy!
In this tutorial, we will use two Arduino Uno to demonstrate the Serial Peripheral Interface…
In this tutorial, we will be making an automatic irrigation system (AIS) with Arduino and…
This tutorial will show you how to use Python Virtual Environment with Raspberry PI computer…
This tutorial will show you how to get betting odds with Raspberry PI by using…
This tutorial will show you how to perform the backup of Raspberry PI (computer board)…
This tutorial will show you how to install Honeygain on a Raspberry PI computer board…