How to Install WordPress on AlmaLinux 8

Prerequisites:

Wordpress requires LAMP stack installed and running

For detailed installation, refer to LAMP Stack on Almalinux 8

Open port for 80 and 443

If firewalld service running, Allow the firewall to HTTP and HTTPS.

firewall-cmd --permanent --zone=public --add-service=http

firewall-cmd --permanent --zone=public --add-service=https

Output:

[root@my ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@my ~]# firewall-cmd --permanent --zone=public --add-service=https
success

Reload firewall using below command,

firewall-cmd --reload

Output:

[root@my ~]# firewall-cmd --reload
success
[root@my ~]#

Start and enable Apache Webserver

Start and enable the Apache Webserver to start after system reboot,

systemctl start httpd

systemctl enable httpd

Start and enable Mariadb

Start and enable MariaDB to start after system reboot,

systemctl start mariadb

systemctl enable mariadb

Secure MariaDB installation

Next, we secure our MariaDB installation and setup a root password for MariaDB,

mysql_secure_installation

Output:

[root@my ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:

Creating the new database

Log into MySQL with the following command,

mysql -u root -p

First, create a new database,

CREATE DATABASE wordpress;

Next, create a new MySQL user account that we will use to operate on WordPress's new database, with username "admin"

CREATE USER `admin`@`localhost` IDENTIFIED BY '<Enter Strong Password here>';

Link the user and DB together by granting our user access to the database,

GRANT ALL ON wordpress.* TO `admin`@`localhost`;

Flush the privileges so that MySQL knows about the user permissions we just added,

FLUSH PRIVILEGES;

Exit out of the MySQL command prompt by typing,

exit

Output:

MariaDB [(none)]> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> CREATE USER `admin`@`localhost` IDENTIFIED BY '<Enetered Password>';
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> GRANT ALL ON wordpress.* TO `admin`@`localhost`;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]>

Download and extract WordPress

Download the wordpress by using curl command and extract the downloaded file

curl https://wordpress.org/latest.tar.gz --output wordpress.tar.gz

tar xf wordpress.tar.gz

Copy the extracted WordPress directory into the /var/www/html directory

cp -r wordpress /var/www/html

File Permissions

Change the permission of the site directory.

chown -R apache:apache /var/www/html/wordpress

chcon -t httpd_sys_rw_content_t /var/www/html/wordpress -R

Navigate your browser:

http://server_IP/wordpress

Start WordPress Installation by clicking on the Run the installation button:

Provide the requested information:

Once the wordpress is installed login with your new user credentials: