How to Install WordPress on a Rocky Linux 8 VPS

Want to install WordPress on a VPS but not sure how? Don't worry, here we will discuss how to install WordPress on a Rocky Linux 8 VPS. If you are using a VPS with a different OS, you can learn how to do it here

By the way, even though this method is specifically for installing WordPress on a Rocky Linux 8 VPS, you can also use this method to install WordPress on CentOS 8, because both use the same base RHEL, so the method used is the same.

But if you have difficulty installing WordPress directly via CLI, it is recommended to use a server control panel like cPanel, Webuzo, CyberPanel, and so on.

How to Install WordPress on a Rocky Linux 8 VPS

For this installation process, we will use the LAMP Stack (Linux, Apache, MySQL/MariaDB, and PHP), so we need to install the LAMP Stack first.

1. Install LAMP Stack

Before installing the LAMP Stack, make sure your DNF repository cache is updated. If you have already performed an update, you can skip this step.

sudo dnf update

In addition to updating the DNF repository cache, we also need to install wget which will be used later to download the latest WordPress file

sudo dnf install wget -y

1.1. Install Apache

After updating the repository cache and installing wget, we can then install Apache so that the website can be displayed when accessed.

sudo dnf install httpd -y

After Apache is installed, enable the rewrite module by adding the command line to the end of the file /etc/httpd/conf/httpd.conf

sudo vi /etc/httpd/conf/httpd.conf

Add this line to the very end of the httpd.conf file

LoadModule rewrite_module modules/mod_rewrite.so

To save the changes, press ESC to enter command mode, then in command mode type :wq! to exit and save the file.

At this point, the Apache installation is complete, but the process is not yet running. To start the Apache process, you can use this command

sudo systemctl start httpd

After the process is started, we can check whether the process is actually running or not with this command

sudo systemctl status httpd
● httpd.service - The Apache HTTP Server   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)   Active: active (running) since Mon 2023-05-29 11:04:10 WIB; 2min 46s ago     Docs: man:httpd.service(8) Main PID: 78544 (httpd)   Status: "Total requests: 2; Idle/Busy workers 100/0;Requests/sec: 0.0126; Bytes served/sec:  64 B/sec"    Tasks: 213 (limit: 4737)   Memory: 24.2M   CGroup: /system.slice/httpd.service           ├─78544 /usr/sbin/httpd -DFOREGROUND           ├─78545 /usr/sbin/httpd -DFOREGROUND           ├─78546 /usr/sbin/httpd -DFOREGROUND           ├─78547 /usr/sbin/httpd -DFOREGROUND           └─78549 /usr/sbin/httpd -DFOREGROUND

Additionally, you can also check whether Apache is running or not by visiting your public IP address in a browser (http://alamat_ip_publik/). If it is running, you will see the default Apache page like this

Cara Install WordPress di VPS Rocky Linux 8 - 1

1.2 Install MariaDB

For WordPress to run, we need to install MariaDB to create and manage the database, because by default Rocky Linux uses MariaDB instead of MySQL, although both have the same function

sudo dnf install mariadb-server -y

After the process is successful, start the MariaDB process so it can be used, and also check its status to see if it has successfully started or not

sudo systemctl start mariadb && systemctl status mariadb
● mariadb.service - MariaDB 10.3 database server   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)   Active: active (running) since Mon 2023-05-29 11:11:44 WIB; 35ms ago     Docs: man:mysqld(8)           https://mariadb.com/kb/en/library/systemd/  Process: 81854 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)  Process: 81784 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)  Process: 81760 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS) Main PID: 81822 (mysqld)   Status: "Taking your SQL requests now..."    Tasks: 30 (limit: 4737)   Memory: 67.3M   CGroup: /system.slice/mariadb.service           └─81822 /usr/libexec/mysqld --basedir=/usr

1.3 Install PHP

Because by default Rocky Linux uses PHP 5.4, we need to use the Remi Repository to install PHP 7.4 or 8.0.

To use PHP 7.4, we can install the Remi Repository first

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

After it is installed, we need to enable the PHP module and install the necessary extensions

sudo dnf module enable php:remi-7.4 && dnf install php php-bz2 php-mysql php-curl php-gd php-intl php-common php-mbstring php-xml -y

After PHP is installed, we need to restart Apache

sudo systemctl restar httpd

2. Create Database

Before downloading and installing WordPress, we need to create a database first to store WordPress data.

mysql -u root

Next, create the database name to be used, for example wpgan_db

create database wpgan_db;

Also create a user who can access the database, for example wpgan_user and use the password wpgan_password_db

CREATE USER 'wpgan_user '@'localhost' IDENTIFIED BY 'wpgan_password_db';

So that the user wpgan_user can access the database wpgan_db, we need to grant access rights to that user

GRANT ALL PRIVILEGES ON wpgan_db.* TO 'wpgan_user'@'localhost';

Perform a flush privileges to refresh access rights, then exit the database

FLUSH PRIVILEGES;quit

3. Download WordPress

We will download this WordPress file to the /tmp folder, then we will set up the database before moving it to the WordPress installation folder

cd /tmp && wget https://WordPress.org/latest.tar.gz

Next, extract the WordPress file that we just downloaded

sudo tar -xzvf latest.tar.gz

Because the WordPress file does not currently have a wp-config.php file, we need to create one by copying the wp-config-sample.php file

sudo cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php

Next, enter the database into wp-config.php according to the database that was created. Because I previously created a database named wpgan_db, user wpgan_user, and password wpgan_password_db, the command used is like this

sudo sed -i 's/database_name_here/wpgan_db/'  /tmp/wordpress/wp-config.phpsudo sed -i 's/username_here/wpgan_user/'  /tmp/wordpress/wp-config.phpsudo sed -i 's/password_here/wpgan_password_db/'  /tmp/wordpress/wp-config.php

After adding the database, we can move the WordPress file to the installation folder located at /var/www/html/.

sudo mv /tmp/wordpress/* /var/www/html/

If you want to use the copy method, you can use this command

sudo cp /tmp/wordpress/* /var/www/html/ -r

4. Add Read Write Permissions

For WordPress to run smoothly, we need to provide read, write, and execute permissions on the WordPress installation files and folders.

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

If your website still cannot be accessed after using the permissions above, you can use chcon

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

To apply changes using chcon, you need to use restorecon

sudo restorecon -Rv /var/www/html/

5. Configure WordPress

Since all steps are complete, we now need to configure WordPress by opening your server's public IP address in a browser, for example http://192.168.8.8.

If all processes were correct, you will be immediately given the option to fill in the website details, as well as a form to create a WordPress account

Cara Install WordPress di VPS Rocky Linux 8 - 2

If all data has been filled in, continue the installation by clicking the button Install WordPress, and congratulations, your WordPress has been successfully installed on a VPS with the Rocky Linux 8 OS.

Cara Install WordPress di VPS Rocky Linux 8 - 3

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...