How to Install WordPress on Rocky Linux 9
WordPress is a Content Management System (CMS), a platform you can use to build and maintain a website without any knowledge of coding. This software enables you to customize just about every aspect of your site.
Prerequisites:
WordPress requires a LAMP stack installed and running
For detailed installation, refer to LAMP Stack on Rocky Linux 9
Update Firewall Settings
The below commands will open or allow the HTTP (port 80) and HTTPS (port 443) and then reload the firewall configuration to effect.
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
Output:
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@server ~]# firewall-cmd --reload
success
Secure MariaDB Installation
Next, we secure our MariaDB installation and setup a root password for MariaDB
mysql_secure_installation
Output:
[root@server ~]# 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, we'll 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 the 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.002 sec)
MariaDB [(none)]> CREATE USER `admin`@`localhost` IDENTIFIED BY 'STRONG PASSWORD HERE';
Query OK, 0 rows affected (0.003 sec)
MariaDB [(none)]> GRANT ALL ON wordpress.* TO `admin`@`localhost`;
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> exit
Download and Extract WordPress
Download the WordPress by using the curl command,
curl https://wordpress.org/latest.tar.gz --output wordpress.tar.gz
Install tar
command to extract wordpress file using below command,
dnf install tar -y
Extract the wordpress file using below command,
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 permissions and change file SELinux security context
chown -R apache:apache /var/www/html/wordpress
chcon -t httpd_sys_rw_content_t /var/www/html/wordpress -R
Allow Apache to access the internet to allow WordPress to download plugins and updates directly from WordPress.org,
setsebool -P httpd_can_network_connect true
Accessing WordPress
Navigate to the following URL via your browser
Start WordPress installation by clicking on the Run the installation button:
Provide the requested information
Once WordPress is installed log in with your new user credentials
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS