WordPress is a very popular PHP based CMS (Content Management System). For small businesses, personal/hobby websites, WordPress can be a lifesaver.  In this article, I am going to show you how to install WordPress on CentOS 8. So, let’s get started.

Installing PHP, Apache and MariaDB:

As I’ve said earlier, WordPress is written on PHP programming language. So, you must have a working LAMP server installed on CentOS 8 in order to run WordPress.

First, update the DNF package repository with the following command:

How to Install WordPress on CentOS 8 centos WordPress

Now, install Apache, PHP, MariaDB with the following command:

$ sudo dnf install mariadb mariadb-server httpd

httpd-tools php php-cli php-json php-gd php-mbstring php-pdo php-xml

phpmysqlnd phppeclzip wget

How to Install WordPress on CentOS 8 centos WordPress

To confirm the installation, press Y and then press .

How to Install WordPress on CentOS 8 centos WordPress

Apache, PHP and MariaDB should be installed.

How to Install WordPress on CentOS 8 centos WordPress

Apache httpd service won’t be running (inactive) by default on CentOS 8.

$ sudo systemctl status httpd

How to Install WordPress on CentOS 8 centos WordPress

Now, start the Apache httpd service with the following command:

$ sudo systemctl start httpd

How to Install WordPress on CentOS 8 centos WordPress

Now, Apache httpd service should be running (active).

$ sudo systemctl status httpd

How to Install WordPress on CentOS 8 centos WordPress  How to Install WordPress on CentOS 8 centos WordPress

Now, add Apache httpd service to the system startup with the following command:

$ sudo systemctl enable httpd

How to Install WordPress on CentOS 8 centos WordPress

mariadb service won’t be running (inactive) by default on CentOS 8.

$ sudo systemctl status mariadb

How to Install WordPress on CentOS 8 centos WordPress

Now, start the mariadb service with the following command:

$ sudo systemctl start mariadb

How to Install WordPress on CentOS 8 centos WordPress

Now, mariadb service should be running (active).

$ sudo systemctl status mariadb

How to Install WordPress on CentOS 8 centos WordPress

Now, add mariadb service to the system startup with the following command:

$ sudo systemctl enable mariadb

How to Install WordPress on CentOS 8 centos WordPress

Creating a Database for WordPress:

Now, you have to create a new MariaDB database for WordPress.

First, login to the MariaDB shell with the following command:

How to Install WordPress on CentOS 8 centos WordPress

Now, type in your password and press . By default, no password is set. So just press if you’re following along.

How to Install WordPress on CentOS 8 centos WordPress

You should be logged into the MariaDB console.

How to Install WordPress on CentOS 8 centos WordPress

Now, create a new MariaDB database wordpress with the following SQL statement:

How to Install WordPress on CentOS 8 centos WordPress

Now, create a new user wordpress with the password secret and grant the user wordpress all privileges (read, write, modify etc.) to the database wordpress with the following SQL statement:

MariaDB> GRANT ALL ON wordpress.* TO ‘wordpress’@‘localhost’ IDENTIFIED BY ‘secret’;

How to Install WordPress on CentOS 8 centos WordPress

Now, for the changes to take effect, run the following SQL statement:

How to Install WordPress on CentOS 8 centos WordPress

Now, exit out of the MariaDB database console as follows:

How to Install WordPress on CentOS 8 centos WordPress

Downloading and Installing WordPress:

WordPress is not available in the official package repository of CentOS 8. So, you must download it from the official website of WordPress and install it on CentOS 8. It’s very easy.

First, navigate to the /var/www directory as follows:

How to Install WordPress on CentOS 8 centos WordPress

Now, download the latest WordPress archive from the official website of WordPress with the following command:

$ sudo wget https://wordpress.org/latest.tar.gz

How to Install WordPress on CentOS 8 centos WordPress

wget is downloading WordPress archive. It may take a few minutes to complete.

How to Install WordPress on CentOS 8 centos WordPress

WordPress archive should be downloaded.

How to Install WordPress on CentOS 8 centos WordPress

The WordPress archive file latest.tar.gz should be in the /var/www directory as you can see in the screenshot below.

How to Install WordPress on CentOS 8 centos WordPress

Now, extract the WordPress archive file latest.tar.gz with the following command:

$ sudo tar xvzf latest.tar.gz

How to Install WordPress on CentOS 8 centos WordPress

How to Install WordPress on CentOS 8 centos WordPress

Once the WordPress archive file latest.tar.gz is extracted, a new directory wordpress/ should be created as you can see in the screenshot below.

How to Install WordPress on CentOS 8 centos WordPress

Now, you can remove the latest.tar.gz file as follows:

$ sudo rm -v latest.tar.gz

How to Install WordPress on CentOS 8 centos WordPress

Now, change the owner and group of the wordpress/ directory and its contents to apache as follows:

$ sudo chown -Rf apache:apache ./wordpress/

How to Install WordPress on CentOS 8 centos WordPress

Now, change the permission or the wordpress/ directory and its content to 775 as follows:

$ sudo chmod -Rf 775 ./wordpress/

How to Install WordPress on CentOS 8 centos WordPress

If you have SELinux enabled (which is very likely on CentOS 8/RHEL 8), run the following command to set the correct SELinux context to the /var/www/wordpress directory and its contents.

$ sudo semanage fcontext -a -t httpd_sys_rw_content_t

“https://linuxhint.com/var/www/wordpress(/.*)?”

How to Install WordPress on CentOS 8 centos WordPress

For the SELinux changes to take effect, run the following command:

$ sudo restorecon -Rv /var/www/wordpress

How to Install WordPress on CentOS 8 centos WordPress

How to Install WordPress on CentOS 8 centos WordPress

Now, create a new Apache configuration file wordpress.conf for WordPress with the following command:

$ sudo vi /etc/httpd/conf.d/wordpress.conf

How to Install WordPress on CentOS 8 centos WordPress

Vi text editor should open. Now, press i to go to INSERT mode.

How to Install WordPress on CentOS 8 centos WordPress

Now, type in the following lines of codes in the wordpress.conf file.

<VirtualHost *:80>


ServerAdmin root@localhost


DocumentRoot /var/www/wordpress

<Directory “https://linuxhint.com/var/www/wordpress”>


Options Indexes FollowSymLinks


AllowOverride all


Require all granted

</Directory>


ErrorLog /var/log/httpd/wordpress_error.log


CustomLog /var/log/httpd/wordpress_access.log common

</VirtualHost>

Finally, the wordpress.conf file should look as shown in the screenshot below.

Now, press , type in :wq! and press to save the file.

How to Install WordPress on CentOS 8 centos WordPress

Now, restart the Apache httpd service with the following command:

$ sudo systemctl restart httpd

How to Install WordPress on CentOS 8 centos WordPress

Apache http service should be active without any errors as you can see in the screenshot below.

$ sudo systemctl status httpd

How to Install WordPress on CentOS 8 centos WordPress

Accessing WordPress:

In order to access WordPress installed on your CentOS 8 machine, you must know the IP address or domain name of your CentOS 8 machine.

You can find the IP address of your CentOS 8 machine with the following command:

As you can see, the IP address of my CentOS 8 machine is 192.168.20.129. It will be different for you. So, make sure to replace it with yours from now on.

How to Install WordPress on CentOS 8 centos WordPress

Now, open your favorite web browser and visit http://192.168.20.129. You should see the following page. Click on Let’s go.

How to Install WordPress on CentOS 8 centos WordPress

Now, type in the MariaDB database information (i.e. Database Name, Username, Password). Leave the Database Host and Table Prefix as it is if you don’t know what they are. Once you’re done, click on Submit

How to Install WordPress on CentOS 8 centos WordPress

Now, click on Run the installation.

How to Install WordPress on CentOS 8 centos WordPress

Now, type in your site details and click on Install WordPress.

Don’t forget to take a note of the Username and Password you’re setting here as you will need them very shortly.

How to Install WordPress on CentOS 8 centos WordPress

WordPress should be installed. Now, click on Log In.

How to Install WordPress on CentOS 8 centos WordPress

Now, type in your site Username and Password and click on Log In.

How to Install WordPress on CentOS 8 centos WordPress

You should be logged in to the WordPress admin panel. You can manage your site from here.

How to Install WordPress on CentOS 8 centos WordPress

So, that’s how you install WordPress on CentOS 8. Thanks for reading this article.

About the author

How to Install WordPress on CentOS 8 centos WordPress

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.