How to install WordPress on CentOS 7

Its time to turn my CentOS cloud server more usable by installing WordPress on it. On my previous tutorial, I have shown a great solution provided by DigitalOcean to create a low cost cloud server. If you prefer Amazon, they also have a great solution (Amazon LightSail) that as cheap as $5 per month to get a reliable cloud server. Today I am going to create a new website with WordPress.

Before we can install WordPress on CentOS 7, make sure you have installed LAMP on CentOS 7. I have summarized the steps to install LAMP on CentOS 7. Follow the link below:

  1. Install Apache webserver on CentOS 7
  2. Install MariaDB/MySQL on CentOS 7
  3. Install PHP on CentOS 7

Once you have those Apache, MySQL and PHP installed on CentOS, we can start installing WordPress on our system.

Steps to install WordPress on CentOS 7

Step 1. Create new Database for WordPress

On Terminal console, we need to log in to MySQL Server and create new database.

root@centos-512mb-sgp1-01 ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 91
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Now create a new database called “wordpress01” or anything you like.

MariaDB [(none)]> create database wordpress01;
Query OK, 1 row affected (0.01 sec)

Now create a new user for example: dhani

MariaDB [(none)]> create user dhani@localhost identified by '12345678';
Query OK, 0 rows affected (0.00 sec)

Grant privileges

MariaDB [(none)]> grant all privileges on wordpress01.* to dhani@localhost identified by '12345678';
Query OK, 0 rows affected (0.00 sec)

Flush privileges and exit

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit;
Bye

Step 2. Install Wordpress

WordPress needs php-gd module to work properly. Install it first prior to WordPress installation

yum install php-gd

Restart Apache

systemctl restart httpd

Download WordPress

[root@centos-512mb-sgp1-01 ~]# wget http://wordpress.org/latest.tar.gz
--2017-05-06 12:29:01--  http://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... 66.155.40.249, 66.155.40.250
Connecting to wordpress.org (wordpress.org)|66.155.40.249|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://wordpress.org/latest.tar.gz [following]
--2017-05-06 12:29:01--  https://wordpress.org/latest.tar.gz
Connecting to wordpress.org (wordpress.org)|66.155.40.249|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8040021 (7.7M) [application/octet-stream]
Saving to: ‘latest.tar.gz’

100%[====================================================================================================>] 8,040,021   3.20MB/s   in 2.4s   

2017-05-06 12:29:04 (3.20 MB/s) - ‘latest.tar.gz’ saved [8040021/8040021]

Extract wordpress

tar-xvf latest.tar.gz

Copy wordpress folder content to apache directory

rsync -avP wordpress/ /var/www/html/

Now create upload directory

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

Change the ownership

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

Step 3. Configure WordPress

Now we need to configure WordPress. First we need to copy the config sample file

cd /var/www/html
cp wp-config.sample.php wp-config.php
nano wp-config.php

Now find the following section:

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘database_name_here‘);

/** MySQL database username */
define(‘DB_USER’, ‘username_here‘);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password_here‘);

Change the red text with the actual wordpress database, username and password we created earlier. In my case this would be:

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress01’);

/** MySQL database username */
define(‘DB_USER’, ‘dhani’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘12345678’);

Step 4. Complete WordPress Installation

The last step is to configure WordPress installation via web browser. Type the IP address of the CentOS 7 server on a web browser and follow the installation wizard.

Select the language

Enter the new site information and press Install to start the installation

You will see the following info when the installation was successfull

Now you can log in to the new WordPress site

Now happy blogging. Thanks for coming to this blog and please subscribe to my social network if you like this website.

 

Admin

Leave a Reply

Your email address will not be published. Required fields are marked *