To install WordPress on Raspberry Pi, you need a web server, PHP, and DB.
The web server mainly uses nginx or apache, and I will explain here based on apache.
In the case of DB, mysql or mariadb is usually used, and I will explain it based on mariadb.
Just execute the commands in the order below, and when asked if you want to install in the middle, just type “y” and move on.
The apt command below is based on Raspberry Pi or Debbian OS, and if it is not Raspberry Pi, you can use it by changing it to the appropriate yum, rpm, etc. depending on the applicable Linux type.
apache installation$ sudo apt install apache2
install php
$ sudo apt install php7.4
install mariadb
$ sudo apt install mariadb-server-10.5
Install a module that makes php use mariadb
$ sudo apt install php-mysql
latest update
$ sudo apt update
$ sudo apt upgrade
restart apache
$ sudo service apache2 restart
Maria DB connection
$ mysql -uroot -p
then enter the password

Create WordPress DB by running the following command while connected to MariaDB
create database wordpress;
then quit; Enter to exit
quit;
This completes the preliminary preparation for WordPress installation.
After that, you can access WordPress by downloading it.
To download WordPress, move it to the default directory of the web service.
$ cd /var/www/html/
Then, you download the wordpress file, and you download it using a file on the web called wget.
It is installed by default on Raspberry Pi, and if you do not have it, you can download it by running $sudo apt install wget.
/var/www/html $ sudo wget http://wordpress.org/latest.tar.gz
If you run it like this, the installation file is first downloaded in a compressed form.
Then unzip it.
/var/www/html $ sudo tar xzf latest.tar.gz
This completes the installation.
However, if you install it like this, the default path becomes /var/www/html/wordpress.
Then, if you want to access it with a browser, you need to connect with domain address/wordpress or ip address/wordpress.
You can use it as is, or if you want to remove wordpress from the address, you can move all files under wordpress under the html directory, which is the upper directory.
/var/www/html $ sudo mv wordpress/* .
After that, delete the original wordpress directory and compressed files.
/var/www/html $ sudo rmdir wordpress
/var/www/html $ sudo rm latest.tar.gz
And finally, you can edit the permissions.
/var/www/html $ sudo chown -R www.data: .
All installations are now complete.
If you access the domain or address in the browser, you can see that the initial WordPress setting screen appears normally.
