WordPress is a free CMS (Content Management System), content management system written using PHP and MySQL, licensed under the GPL. WordPress is a platform where all kinds of content can be edited and published, not just as an article writing and editing or blogging system.
64.4% of known content management systems and 43% of all websites use WordPress. Let's talk about installing this popular CMS software on Rocky Linux 9.
Steps to install WordPress
Let's explain the installation step by step.
Step 1: Install Httpd and LAMP Stack
For the WordPress web interface, the httpd package is first installed:
[foc@rocky9 ~]$ sudo dnf install httpd -y
Then httpd service is enabled:
[foc@rocky9 ~]$ sudo systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
And the service is started:
[foc@rocky9 ~]$ sudo systemctl start httpd
Added firewall rules for httpd service:
[foc@rocky9 ~]$ sudo firewall-cmd --add-service=http --permanent success [foc@rocky9 ~]$ sudo firewall-cmd --reload success
A LAMP stack is a group of open-source software that is typically installed together to enable a server to host dynamic websites and web apps. You can find more detailed information about LAMP Stack installation in our "Install LAMP Stack on Rocky Linux 8 [Step-by-Step]" article. Now let's proceed by installing the necessary LAMP Stack packages for WordPress installation:
[foc@rocky9 ~]$ sudo dnf install -y php php-zip php-intl php-mysqlnd php-dom php-simplexml php-xml php-xmlreader php-curl php-exif php-ftp php-gd php-iconv php-json php-mbstring php-posix php-sockets php-tokenizer
This step is complete
Step 2: Create the Database and a User
If you want to do database operations with phpMyAdmin, not from the terminal, you can review the "Install phpMyAdmin on Rocky Linux 9 [Step-by-Step]" article for phpMyAdmin installation.
For MariaDB Server, install the following package:
[foc@rocky9 ~]$ sudo dnf -y install mariadb-server
The service is enabled:
[foc@rocky9 ~]$ sudo systemctl enable mariadb.service
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.
Then the service is started:
[foc@rocky9 ~]$ sudo systemctl start mariadb.service
We will create a database for user, password and wordpress in MariaDB. Enter MariaDB:
[foc@rocky9 ~]$ sudo mysql -uroot Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 4 Server version: 10.5.16-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE mywordpress_db; Query OK, 1 row affected (0.000 sec) MariaDB [(none)]> CREATE USER 'wp_foc'@'localhost' IDENTIFIED BY 'Pp123456'; Query OK, 0 rows affected (0.005 sec) MariaDB [(none)]> GRANT ALL ON mywordpress_db.* TO 'wp_foc'@'localhost'; Query OK, 0 rows affected (0.005 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> exit; Bye
We entered the following values, make a note of the information you entered:
- Database: mywordpress_db
- User Name: wp_foc
- Password: Pp123456
Step 3: Download and Extract WordPress
Install the following packages for WordPress download and unzip:
[foc@rocky9 ~]$ sudo dnf install wget unzip -y
Download wordpress with wget:
[foc@rocky9 ~]$ wget https://wordpress.org/latest.zip
--2022-10-03 10:43:52-- https://wordpress.org/latest.zip
Resolving wordpress.org (wordpress.org)... 198.143.164.252
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22772803 (22M) [application/zip]
Saving to: ‘latest.zip’
latest.zip 100%[=============================>] 21.72M 1.81MB/s in 11s
2022-10-03 10:44:03 (1.99 MB/s) - ‘latest.zip’ saved [22772803/22772803]
Extracting from zip file:
[foc@rocky9 ~]$ unzip latest.zip
Move the wordpress directory under /var/www/html/
:
[foc@rocky9 ~]$ sudo mv wordpress /var/www/html/
Authorize WordPress directory and subdirectories:
[foc@rocky9 ~]$ sudo chown -R apache:apache /var/www/html/wordpress [foc@rocky9 ~]$ sudo chmod -R 775 /var/www/html/wordpress
Configure the SELinux context for the directory and its contents:
[foc@rocky9 ~]$ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/wordpress(/.*)?" [foc@rocky9 ~]$ sudo restorecon -Rv /var/www/html/wordpress
The wp-config-sample.php
file is renamed to wp-config.php
:
[foc@rocky9 ~]$ sudo mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
The following changes are then applied:
[foc@rocky9 ~]$ sudo vi /var/www/html/wordpress/wp-config.php
define( 'DB_NAME', 'mywordpress_db' );
/** Database username */
define( 'DB_USER', 'wp_foc' );
/** Database password */
define( 'DB_PASSWORD', 'Pp123456' );
Finally, http service is restarted:
[foc@rocky9 ~]$ sudo systemctl restart httpd
Step-4 Login WordPress GUI
After package installations, type http://serverip_address/wordpress into a web browser:
For example: http://192.168.122.238/wordpress/wp-admin/install.php
- Site Title
- Username
- Password
- Your Email
Enter the above information and press the Install WordPress button.
Make a note of your username and password.
Enter your username and password.
Welcome to WordPress!
The current WordPress installation is complete.
Summary
The popular CMS software WordPress was installed in this article. System resources may vary depending on the type of content you want to install. Let's share an example source:
- Disk space: At least 1 GB.
- Database: MySQL 5.015 or higher
- RAM: At least 512 MB.
- CPU: At least 1.0 GHz.
Preferences
wordpress.org - How to install WordPress