Setup WordPress on CentOS 9 Stream

Setup Wordpress on CentOS 9 Stream

This is a guide on how to install WordPress on CentOS 9 Stream but it will also work on older versions of CentOS.

WordPress Configuration On CentOS 9 Stream

Prepare the Environment

Install CentOS 9 Stream on your server.

Update the system packages using the package manager:

Example
sudo dnf update

Install LAMP Stack

Install Apache web server:

Example
sudo dnf install httpd

Install MariaDB (MySQL compatible database server):

Example
sudo dnf install mariadb-server

Install PHP and required modules:

Example
sudo dnf install php php-mysqlnd php-gd php-xml php-mbstring

Configure the LAMP Stack:

Start and enable Apache:

Example
sudo systemctl start httpd
sudo systemctl enable httpd

Start and enable MariaDB:

Example
sudo systemctl start mariadb
sudo systemctl enable mariadb

Secure your MariaDB installation by running:

Example
sudo mysql_secure_installation

Create a MySQL Database and User

Log in to the MariaDB server as the root user:

Example
sudo mysql -u root -p

Create a new database:

Code Example
CREATE DATABASE wordpress;

Create a new user and grant privileges to the database:

Code Example
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;

Download and Configure WordPress

Download the latest version of WordPress:

Example
sudo dnf install wget
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz

Move the extracted files to the Apache web root directory:

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

Configure the WordPress site by creating the wp-config.php file:

Example
cd /var/www/html/
sudo mv wp-config-sample.php wp-config.php
sudo vi wp-config.php

Update the database details in wp-config.php to match the database and user you created earlier

Set appropriate ownership and permissions for WordPress files:

Example
sudo chown -R apache:apache /var/www/html/
sudo chmod -R 755 /var/www/html/

Edit the Apache configuration file:

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

Update the DirectoryIndex directive to include index.php:

Example
DirectoryIndex index.php index.html

Save the file and exit.

Restart Apache:

Example
sudo systemctl restart httpd

Complete WordPress Installation

  • Open a web browser and access your server’s IP address or domain name.
  • Follow the WordPress installation wizard, providing the required information such as site title, admin username, password, etc.

That’s it! You should now have WordPress successfully installed on CentOS 9 Stream. Remember to consult the official documentation and adapt the steps as needed based on the specific CentOS version you are using.

Related Articles

Notice an error?

Help us improve our content by reporting any issues you find.