How to install WordPress on Alma Linux 8 – 2023

If you are using Alma Linux 8 on your server then you need to know how to install WordPress on Alma Linux 8 if you want to use WordPress on your server.

The instruction is simple, but you need to know the basics of the following knowledge:

  • Connecting to the server via SSH
  • Understanding the concept of commands and how the Linux console works

Of course, it is assumed that you are able to follow this guide to install WordPress on Alma Linux 8.

Also, this guide is done on a fresh install that is not security hardened (yet). If you plan to make this a production site, you should also strengthen the security of your server and WordPress.

I did the complete installation on a VPS server at Time4VPS, which offers good VPS servers and low prices.

Now that we are past the short introduction to the whole story let’s see how to install WordPress on Alma Linux 8.

Step 1: Do the update of your Alma Linux 8

dnf update

Step 2: Install the httpd (it is Apache)

dnf install httpd

Enable httpd to run with system:

systemctl enable --now httpd

You should get a printout like this if everything went well:

[root@rebootos ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@rebootos ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2023-04-02 00:52:42 EEST; 29s ago
Docs: man:httpd.service(8)
Main PID: 109354 (httpd)
Status: "Running, listening on: port 80"
Tasks: 213 (limit: 3276)
Memory: 17.1M
CGroup: /system.slice/httpd.service
├─109354 /usr/sbin/httpd -DFOREGROUND
├─109355 /usr/sbin/httpd -DFOREGROUND
├─109356 /usr/sbin/httpd -DFOREGROUND
├─109358 /usr/sbin/httpd -DFOREGROUND
└─109478 /usr/sbin/httpd -DFOREGROUND
Apr 02 00:52:42 rebootos.com systemd[1]: Starting The Apache HTTP Server…
Apr 02 00:52:42 rebootos.com systemd[1]: Started The Apache HTTP Server.
Apr 02 00:52:42 rebootos.com httpd[109354]: Server configured, listening on: port 80
[root@rebootos ~]#

Enable the rewrite_module on Alma Linux 8 by opening the configuration file with a nano text editor:

nano /etc/httpd/conf/httpd.conf

At the bottom of that file, in the last line, add this line:

LoadModule rewrite_module modules/mod_rewrite.so

Step 3: Install mariadb

dnf install mariadb maridb-server

Enable mariadb to run with system:

systemctl enable --now mariadb

In case you get this error, try restarting the server:

[root@rebootos ~]# systemctl enable --now mariadb
Failed to enable unit: Unit file mysql.service does not exist.

To restart the server type:

reboot

After restarting the server, try to enable it again:

systemctl enable --now mariadb

You should get a printout like this if everything went well:

[root@rebootos ~]# systemctl enable --now mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@rebootos ~]#

Just in case, check the status of this service:

systemctl status mariadb

You should get a printout like this if everything went well:

systemctl status mariadb
mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2023-04-02 01:12:46 EEST; 28s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 932 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 799 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
Process: 775 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 901 (mysqld)
Status: "Taking your SQL requests now…"
Tasks: 30 (limit: 3276)
Memory: 95.9M
CGroup: /system.slice/mariadb.service
└─901 /usr/libexec/mysqld --basedir=/usr

Step 4: Let’s strengthen the security of the Mariadb installation

This is a command to harden the security of the Mariadb installation that will start an automatic process. You can freely confirm the action with “y” for each question:

mysql_secure_installation

Don’t do it blindly, read carefully what you confirmed:

Important: You will need to assign a root password for Mariadb. It is not the root password of the server, but you should set a new password only for Mariadb. Write that password down somewhere.

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

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]

New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
… Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
… Success!

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y

Dropping test database…
… Success!

Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
Reload privilege tables now? [Y/n] y
… Success!

Cleaning up…

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Step 5: Install PHP on Alma Linux 8 for WordPress installation

Install the remi repository to install the PHP 8 version:

dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Run update:

dnf update -y

Reset php:

dnf module reset php -y

Enable remi module:

dnf module enable php:remi-8.0 -y

Run update:

dnf update -y

Install php modules:

dnf install php php-{bz2,mysqli,curl,gd,intl,common,mbstring,xml}

Restart apache:

systemctl restart httpd

Step 6: Create database on Alma Linux 8 for WordPress installation

Start the mysql instance and enter the root password (which you created earlier during Mariadb security strengthening):

mysql -u root -p

Create database, replace “wp1” with something you want (remember or write down the database name – you’ll need it later):

CREATE DATABASE wp1;

Create user, replace ivan with something you want and replace password with strong phraze (remember or write down the username and password – you’ll need it later):

CREATE USER 'ivan'@localhost IDENTIFIED BY 'password';

Grand privilegies to your user with your password, replace ivan with your user (the user you created with the previous command) and replace password (the password you created with the previous command):

GRANT ALL PRIVILEGES ON wp1.* TO 'ivan'@localhost IDENTIFIED BY 'password';

Flush privileges:

FLUSH PRIVILEGES;

and exit from mysql instance:

exit;

Step 7: Install WordPress on Alma Linux 8

Download the WordPress package from the official site using wget:

wget http://WordPress.org/latest.tar.gz

Untar that package:

tar -xzvf latest.tar.gz

Move wordpress to /var/www/html/

mv wordpress/* /var/www/html/

Add privileges so that apache can properly manage the folder where the WordPress site is located:

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

To complete the installation of WordPress on Alma Linux 8, go to the IP address of your server (type it into the browser).

If you see a screen like this, well done master!

Now you can finish installing WordPress on Alma Linux 8. In the step asking for database information, enter the database name, database username and password for the database that we created in step number 6.

how to install wordpress on alma linux 8

That’s it. If you were expecting more steps and complications, it won’t happen.

Installing WordPress on Alma Linux 8 is a simple process. It’s a bit more difficult to set up the rest of the server and work on server security, but that’s something I’ll write about in new texts.

If you are interested: Instructions for installing WordPress on an Ubuntu server.

Author, Ivan Blagojević

Engineering Lead at Adriahost. I spend most of my time on Linux operating systems with cPanel/WHM panels.

I help people solve problems and choose the right hosting for their site.

I write here in my spare time.

Time4VPS - VPS hosting in Europe