Red Hat

How to Install WordPress on Rocky Linux 8

How to Install WordPress on Rocky Linux 8

WordPress is a widely used content management system for hosting static and dynamic websites. It’s free and open-source, and it’s written in PHP with MariaDB/MySQL as the database backend. WordPress is made for small enterprises, personal blogs, and online shopping. WordPress is becoming more popular by the day, and it’s a terrific way to get a website up and running quickly.

In this article, we will go through the installation of WordPress using the LAMP stack on Rocky Linux 8.

Step 1: Install LAMP Stack

Before starting, the LAMP stack must be installed in your system. First, let’s install Apache and MariaDB with the command:

$ sudo dnf install httpd mariadb-server -y

After that, install PHP and the required PHP extensions on your system.

First, reset the default PHP 7.2 with the following command:

$ sudo dnf module reset php

Now, enable the PHP version you wish to install. In this guide, we will use PHP 7.4.

$ sudo dnf module enable php:7.4

Next, install PHP 7.4 with some common required extensions as follows:

$ sudo dnf install php php-cli php-json php-gd php-mbstring php-pdo php-xml php-mysqlnd php-pecl-zip curl -y

Step 2: Create a Database for WordPress

WordPress needs a database to store your site’s configuration settings, usernames, posts, pages, and themes among others. You need to create a database and user for WordPress:

First, log in to the MariaDB Database as shown:

$ sudo mysql -u root -p

Next, create a database and user for WordPress as shown:

CREATE DATABASE wordpressdb;
CREATE USER `wordpressuser`@`localhost` IDENTIFIED BY 'strong@password';

Next, grant all the privileges on the WordPress database to the user. Run:

GRANT ALL ON wordpressdb.* TO `wordpressuser`@`localhost`;

Then apply the changes and exit.

FLUSH PRIVILEGES;
EXIT;

Step 4: Download WordPress

At the time of this writing, the latest version of WordPress is 5.8.1 . To download it from the WordPress official site, use the following wget command:

$ wget https://wordpress.org/latest.tar.gz -O wordpress.tar.gz

Once downloaded, extract the contents of the archive file. Run:

$ tar xf wordpress.tar.gz

Next, copy the unzipped WordPress directory to the /var/www/html folder:

$ sudo cp -R wordpress /var/www/html/

Then, change the ownership of the WordPress folder to apache user and group. Execute the command:

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

Also, set the directory permissions so as to allow global users to access WordPress content. Run:

$ sudo chmod -R 775 /var/www/html/wordpress

Thereafter, configure the SELinux context for the WordPress directory.

$ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/wordpress(/.*)?"

To apply the SELinux changes, execute the command:

$ sudo restorecon -Rv /var/www/html/wordpress

Step 5: Configure Apache to Host WordPress

In this step, we will create an Apache virtual host file for WordPress. This will point Apache to the WordPress directory on your system.

Run the following command:

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

Append the following lines to the file:

<VirtualHost *:80>

ServerName server-IP or FQDN

ServerAdmin root@localhost

DocumentRoot /var/www/html/wordpress

<Directory "/var/www/html/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>

Save and exit the file. Then, restart Apache for the changes to be applied.

$ sudo systemctl restart httpd

Step 6: Access WordPress Installer

Now that all the configurations are done, finalize the WordPress installation using the web wizard. Open your browser and access the WordPress installer using your server’s IP.

$ http://server-IP/

Select a language then click on Continue to proceed with the installation.

Next, provide your database details and click Submit.

Once you have connected to your database successfully, you will see the following page. Click on Run installation to proceed.

Thereafter, create a user and set a strong password for the Admin user. Take note of your credentials since you will need them to log in to Worpress later.

Click on install WordPress. After it is done, you will see a notification confirming that the installation was successful.

Now, log in to WordPress using your credentials.

This takes you to the WordPress dashboard shown below. Now you can start to explore how to fully utilize WordPress for your websites.

Conclusion

You have now successfully installed WordPress on Rocky Linux 8. You are now ready to create your blog or website.

Similar Posts