How To Install WordPress on CentOS 7

Step One — Create a MySQL Database and User for WordPress

Log into MySQL with the following command,

mysql -u root -p

You will be prompted for the password that you set for the root account when you installed MySQL.

First, we'll create a new database,


Next, create a new MySQL user account that we will use to operate on WordPress's new database, with username "wordpressuser"

CREATE USER [email protected] IDENTIFIED BY 'password';

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

GRANT ALL PRIVILEGES ON wordpress.* TO [email protected] IDENTIFIED BY 'password';

Flush the privileges so that MySQL knows about the privilege changes made:


Exit out of the MySQL command prompt by typing:


Step Two — Install WordPress

Install PHP, Apache and PHP-GD,

yum install httpd php php-mysql php-gd

Now we need to restart Apache so that it recognizes PHP:

service httpd restart

Download the latest version of wordpress,

cd ~

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/*

Step Three — 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 modifications we need to make to this file are to the parameters that hold our database information. We will need to find the section titled MySQL settings and change the DB_NAME, DB_USER, and DB_PASSWORD variables in order for WordPress to correctly connect and authenticate to the database that we created.

Fill in the values of these parameters with the information for the database that you created. It should look like this:

// ** 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.

Step Four — 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,


Last modified: October 09 2017 05:18:04