How To Install WordPress on CentOS

WordPress is a free and open-source content management system written in hypertext preprocessor language and paired with a MySQL or MariaDB database with supported HTTPS. This is one of the most preferred blogging tool by content creators through out the world and also by small businesses.

Prerequisites:

Create a MariaDB Database and User for WordPress

Log into MariaDB with the following command,

mysql -u root -p

Enter the password for the root account you set when you installed MariaDB.

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 username "wordpressuser"

CREATE USER wordpressuser@localhost IDENTIFIED BY 'password';

Link the user and DB together by granting our user access to the database,

GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';

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

Install WordPress

Install the required packages to successfully run the below steps,

yum install wget tar

Download the latest version of wordpress,

cd /root
wget http://wordpress.org/latest.tar.gz

Extract the archived files to rebuild the WordPress directory,

tar -xzvf latest.tar.gz

Move the unpacked files to Apache's document root,

mv /root/wordpress/ /var/www/html/

Create directory for uploads,

mkdir /var/www/html/wp-content/uploads

Use chown to grant ownership to Apache's user and group:

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

Configure WordPress

Begin by moving into the Apache root directory where you installed WordPress:

cd /var/www/html

The main configuration file that WordPress relies on is called wp-config.php.

cp wp-config-sample.php wp-config.php

Now that we have a configuration file to work with, let's open it in a text editor:

nano wp-config.php

The only changes we need to make to this file are under the section titled MySQL settings and change the DB_NAME, DB_USER, and DB_PASSWORD variables.

Fill in the values of these parameters with the information for the database that you created. It should look like this, Please remember to change "password" to the password you setup above,

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password');

These are the only values that you need to change, so save and close the file when you are finished.

Complete Installation Through the Web Interface

You'll need to complete the WordPress installation through the web interface, Visit the following URL, replace server_domain_name_or_IP_Address with your VPS IP or domain name and follow the instructions on screen,

http://server_domain_name_or_IP_Address