How to install WordPress on CentOS7

Introduction

WordPress is a free web content management system (CMS), which occupies 30% of the entire Internet at this moment. This means that 30% of all internet sites are built using WordPress. WordPress is a tool to create or manage websites in simple language. WordPress has gained popularity due to its simplicity in all areas of content publishing, editing, administration, website content.

Prerequisite

Before installing WordPress, you must see that your root is configured. You must also install LAMP before installing your WordPress.

Step-One

First of all, create a MySQL database and user for WordPress.

Login to the root user on your server. To create a new database, login to your MySQL using the following command.

mysql -u root -p

Here you will need a MySQL root user password. Enter the root password you used to set up MySQL and press Enter. When you complete the login, you will receive a command prompt from MariaDB.

To create a database, use the following command.

CREATE DATABASE your_database_name; 

Now you have to create a user for the database. Use the following command to create a user. 

CREATE USER username@localhost IDENTIFIED BY 'password';

 

Now you have to connect with the database and the user. Use the following command to connect the database and the user. 

GRANT ALL PRIVILEGES ON your_database_name.* TO username@localhost IDENTIFIED BY 'password'; 

Now that the user has access to the database, you have to flush his privileges so that MySQL can know about the change in the recent privilege you created:

FLUSH PRIVILEGES;

Now, you can get out of MySQL. Use the following command to return to SSH.

exit

Step – Two

Install WordPress

Before installing WordPress you need to install a PHP module, install the module with the following command.

sudo yum install php-gd

After installing the module, restart Apache.

sudo service httpd restart

Download the update version of WordPress by following the command.

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

Now you have to extract files in your WordPress directory.

tar xzvf latest.tar.gz

A folder has been created in your home directory named WordPress. If you want, you can finish your WordPress installation here. But if you want, if you keep the data out of the directory, then follow the commands below.

sudo rsync -avP ~/wordpress/ /var/www/html/
mkdir /var/www/html/wp-content/uploads
sudo chown -R apache:apache /var/www/html/*

 

This change will create web server and modify WordPress files, because of which it can upload content to your server.

Step – Three

Configure WordPress

Now you have to setup MySQL database's information in WordPress's configuration files. To do this, follow the commands below.

cd /var/www/html

Now you have to edit the default configuration file.

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

Now use the following command to open the configuration file in a text editor.

vi wp-config.php

After the file is open, you have to save the name of mysql database, user name, and user password.

// ** 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');

Save and close the file with all the information right here.

Step – Four

Complete installation WordPress on the web interface.

First of all, you need to browse through your server's IP from the internet browser. After browsing with the server's IP, you will see the Welcome page of WordPress.

Here you need to enter your site title, username, password, then click on "Install WordPress" button.

After clicking on the Install WordPress button you will see a page like the following.

Now click on the login button.

Login here with your username and password. After logging in, you will see WordPress's dashboard like the following pages.

Finish the work of your WordPress installation.