How to Install and Configure WordPress on CentOS 7 in 3 Steps


Published on 15th Jul 2019 by Mr. Maregedze || Edited on 16th Jul 2019. 808

How to Install and Configure WordPress on CentOS 7 in 3 Steps

Step 1: Install Required Modules

Each Content Management System needs some certain modules to exist in your server for it to perform well. WordPress is no exception. For example WordPress needs php-gd in order to work with images, do installations and other things. Let us now install these PHP modules by running the following command:

yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel

Now we need to restart our Web Server to reflect all the new changes. Run the following command to restart Apache:

systemctl restart httpd.service

This was the first step. Very easy, isn't it? Just one more thing before we start installing WordPress. Run the following command to check for any updates that may be required:

yum update

How to Install and Configure WordPress on CentOS 7 in 3 Steps

Step 2: Download WordPress CMS

If you like you may want to enter into any other directory to save your files while doing this. However in this tutorial I will choose to remain in ~ and proceed. Your server may not have wget required too download files from the internet directly into your server. Just to confirm run the following command:

yum –y wget

After this you have either been notified you already have wget or it was installed successfully. Let us now go ahead and install our WordPress site. Although you can always find latest version of WordPress from several internet websites I recommend you to use the WordPress Repository. Run the following command to download the latest version of WordPress from the WordPress Repository using wget:


Now you must have a file named in your server. Run the following command to confirm this:


Good job! You have it. In order to use this file we must extract files first into our installation directory. To make you understand each step, I will extract them into the same folder first then I move them to the installation folder manually. Run the following command to extract files:


Now you must have a folder named wordpress in your current location. Let us move it to our installation folder. Normally your public directory will be in /var/www/html. You may need to put files into a customized directory like ‘site’. Run the following command to move ‘wordpress’ into /var/www/html/site:

mv wordpress /var/www/html
mv /var/www/html/wordpress /var/www/html/site

WordPress site uses a database. We must now create a database to be used by our website. Run the following command to create a database and the user:

mysql -u root –p

You will see now that you are logged in to your MySQL server after entering your root password. Run the following command and specify values according to your taste. Each command must be placed after mysql>:

CREATE DATABASE wp_database;
GRANT ALL PRIVILEGES on wp_database.* to 'wp_user'@'localhost identified by 'wp_password';

So far you have created a user and a database managed by that user. You can now logout of MySQL Server. Run the following command and return to your WordPress installation:

systemctl restart mysqld.service

So far you have downloaded WordPress and moved it to your installation folder. You have also created the database and the database user. Let us move to the last step.

How to Install and Configure WordPress on CentOS 7 in 3 Steps

Step 3: Configure WordPress

Let us start by granting permissions to the apache server. The following commands run after another will change file ownership and give correct permission to your WordPress files in /var/www/html/site:

chown -R apache:apache /var/www/html/site
chmod -R 755 /var/www/html/site

You will notice these files and folders do not come with some required folders and files. Let us now create them one after another. The following command will create uploads folder for you:

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

You must always make sure it is owned by the right user. Run the following command to do so:

chown -R :apache /var/www/html/site/wp-content/uploads

WordPress depends on a file named wp-config.php. We must create this file from the sample file that we already have. Make sure you are in the right folder now. Use cd to change your location like this:

cd /var/www/html/site

Run the following command to rename the sample file into wp-config.php:

mv wp-config-sample.php wp-config.php

Now we are ready to put our database credentials into this file. I will use Nano text Editor in this tutorial. This command will open the edit window to make the changes:

nano wp-config.php

Change these values accordingly:

/** The name of the database for WordPress */
define('DB_NAME', 'wp_database');
/** MySQL database username */
define('DB_USER', 'wp_user');
/** MySQL database password */
define('DB_PASSWORD', 'wp_password');

Good job! You have configured everything you need. Now you can go to your website URL and start customizing your website. If your domain is not yet pointing to this server or at least to this location you can use http://ip-address/site just to proceed although this may complicate things in future. If you finish the installation in the last suggested location, you will need to edit database manually when you finally point your domain.

This article was written by Masimba Maregedze. If you would like more information or help with your website simply get in touch with me by sending a message using a form on contact page. You can as well comment on this post for general information on this topic.

Tutorial || Masimba Maregedze 808 3

Great article and very helpful. I am very glad that I actually managed to install WordPress on my server. Thank you very much for the tutorial it was very simple to follow up.

Kuda Sibanda on 17th Jul 2019

Start Commenting

Write Comment