Wordpress

How to Install WordPress on CentOS 8: A Comprehensive Guide

Welcome to the Greenhost.Cloud blog! Today, we’re diving into the world of WordPress, one of the most popular content management systems (CMS) out there. If you’re looking to set up your own WordPress site on a CentOS 8 server, you’ve come to the right place. In this step-by-step guide, we’ll walk you through the process of installing WordPress, empowering you to create your own website or blog in no time.

Prerequisites

Before we dive into the installation process, ensure you have the following:

  1. CentOS 8 Server: A virtual private server (VPS) or dedicated server running CentOS 8.
  2. Root Access: You need to have root or sudo privileges on the server.
  3. LAMP Stack: The Light, Apache, MySQL, PHP (LAMP) stack should be installed on your CentOS 8 server.

If you haven’t installed LAMP yet, you can follow these steps:

Step 1: Install the LAMP Stack

  1. Update your system packages:
   sudo dnf update -y
  1. Install Apache:
   sudo dnf install httpd -y
  1. Start and enable Apache:
   sudo systemctl start httpd
   sudo systemctl enable httpd
  1. Install MySQL (MariaDB):
   sudo dnf install mariadb-server -y
  1. Start and secure MariaDB:
   sudo systemctl start mariadb
   sudo systemctl enable mariadb
   sudo mysql_secure_installation

Follow the prompts to secure your installation.

  1. Install PHP and required extensions:
   sudo dnf install php php-mysqlnd php-fpm php-xml php-mbstring php-curl -y
  1. Restart Apache:
   sudo systemctl restart httpd

Step 2: Create a Database for WordPress

  1. Log in to the MariaDB shell:
   sudo mysql -u root -p
  1. Create a database (replace wordpress_db with your preferred database name):
   CREATE DATABASE wordpress_db;
  1. Create a user (replace wordpress_user and password with your chosen username and password):
   CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
  1. Grant privileges to the user on the database:
   GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
   FLUSH PRIVILEGES;
   EXIT;

Step 3: Download and Configure WordPress

  1. Navigate to your web root directory:
   cd /var/www/html
  1. Download the latest version of WordPress:
   sudo dnf install wget -y
   wget https://wordpress.org/latest.zip
  1. Install unzip (if not already installed):
   sudo dnf install unzip -y
  1. Unzip the WordPress files:
   sudo unzip latest.zip
  1. Set the correct permissions:
   sudo chown -R apache:apache /var/www/html/wordpress
   sudo chmod -R 755 /var/www/html/wordpress
  1. Create a configuration file:
   cd wordpress
   cp wp-config-sample.php wp-config.php
  1. Edit the wp-config.php file:
   sudo nano wp-config.php

Update the following lines to match your database details:

   define('DB_NAME', 'wordpress_db');
   define('DB_USER', 'wordpress_user');
   define('DB_PASSWORD', 'password');

Step 4: Configure Apache

  1. Create a new configuration file for your WordPress site:
   sudo nano /etc/httpd/conf.d/wordpress.conf
  1. Add the following configuration:
   <Directory "/var/www/html/wordpress">
       AllowOverride All
   </Directory>
  1. Enable the Rewrite Module:
   sudo dnf install mod_rewrite
  1. Restart Apache:
   sudo systemctl restart httpd

Step 5: Complete the Installation Through the Web Interface

  1. Open your web browser and go to:
   http://your-server-ip/wordpress
  1. You should see the WordPress installation page. Follow the prompts to set up your site title, username, password, and email address.
  2. Complete the installation by clicking the “Install WordPress” button.
  3. After installation, login to your new WordPress site at:
   http://your-server-ip/wordpress/wp-admin

Conclusion

Congratulations! You’ve successfully installed WordPress on CentOS 8. This powerful CMS opens up a world of possibilities for creating and managing your website. Don’t forget to keep your system and WordPress installation updated for security and performance.

We hope you found this guide helpful. If you have any questions or need further assistance, feel free to reach out in the comments section below. Happy blogging!


For more tutorials and tips on managing your web presence, stay tuned to the Greenhost.Cloud blog!