Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
i | P a g e
Table of Contents Overview ....................................................................................................................................................... 1
Applies To .................................................................................................................................................. 1
Pre-requisites ............................................................................................................................................ 1
Installation – Apache Webserver .................................................................................................................. 1
Check Package – httpd .............................................................................................................................. 1
Install Package – httpd .............................................................................................................................. 1
Service Management .................................................................................................................................... 2
httpd Service – Enable .............................................................................................................................. 2
httpd Service – Start ................................................................................................................................. 2
httpd Service – Disable ............................................................................................................................. 3
httpd Service – Open Port (AWS Security Group) ..................................................................................... 3
httpd Service – Launch Website ............................................................................................................... 3
Install – PHP, PHP-MySql ............................................................................................................................... 4
Validate PHP Installation ........................................................................................................................... 4
Launch PHP Info Webpage ........................................................................................................................ 5
Install – Mariadb Server ................................................................................................................................ 6
Check Package – Mariadb Server .............................................................................................................. 6
Install Package – mariadb Server .............................................................................................................. 6
Enable – Service mariadb .......................................................................................................................... 6
Start – Service mariadb ............................................................................................................................. 7
Create Database – blog ............................................................................................................................. 8
Connect Database – blog .......................................................................................................................... 8
Securing Mariadb – Database ....................................................................................................................... 8
Securing Mariadb – Login Password ......................................................................................................... 9
Securing Mariadb – Confirm Password Change ........................................................................................ 9
Securing Mariadb – Set New Password .................................................................................................... 9
Securing Mariadb – Remove Anonymous User ...................................................................................... 10
Securing Mariadb – Disallow root Login Remotely ................................................................................. 10
Securing Mariadb – Remove test Database and Access ......................................................................... 10
Securing Mariadb – Reload Privilege Tables ........................................................................................... 11
Install WordPress ........................................................................................................................................ 11
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
ii | P a g e
Download Package .................................................................................................................................. 11
Extract Package ....................................................................................................................................... 12
Configure Wordpress .................................................................................................................................. 12
Rename Folder ........................................................................................................................................ 12
Rename Sample Configuration File ......................................................................................................... 13
Configure Database Parameters ............................................................................................................. 13
WordPress Portal – Start Page ................................................................................................................ 14
WordPress Portal – Install WordPress .................................................................................................... 14
WordPress Portal – Login ........................................................................................................................ 15
WordPress Portal – Administrator Login ................................................................................................ 15
WordPress Portal – Dashboard ............................................................................................................... 16
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
1 | P a g e
Overview
The purpose of this document is to install and configure WordPress on AWS and local database on RHEL
7 or CentOS 7.
Applies To
CentOS 7, RHEL 7
Pre-requisites
Apache httpd
Firewall Configuration (Open port) – 80
PHP, PHP-MYSQL
MariaDB – (MySQL)
Installation – Apache Webserver
First and foremost thing that you need to do install WordPress, is the install Apache httpd on the server.
Check Package – httpd
Before you install the httpd package on the server, check whether the package is already installed, to
check run the command.
rpm -qa | grep httpd
Install Package – httpd
After validating the package installation status, to install httpd package run the command;
yum install httpd -y
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
2 | P a g e
Service Management
httpd Service – Enable
After installation, next step is to enable the service which will start the service by default at multi-user
Runlevel, run the command;
systemctl enable httpd
If the service is disabled which is default setting, it create a new symbolic link in the folder “multi-
user.target.wants” for the service.
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-
user.target.wants/httpd.service'
httpd Service – Start
The next steps is to start the service to start the service, to start run the command;
systemctl start httpd
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
3 | P a g e
httpd Service – Disable
In order to disable the service to start on boot run the command; Its optional. Though every time the
server is rebooted httpd service has to be started manually.
systemctl disable httpd.service
If the service is already enabled, it remove existing symbolic link in the folder “multi-user.target.wants”
for the service.
rm '/etc/systemd/system/multi-user.target.wants/httpd.service'
httpd Service – Open Port (AWS Security Group)
The next steps is to open port “80” in the inbound rules of the security group wherein the server is
associated, in the AWS Management console. After adding the new rule, click on “Save” button.
httpd Service – Launch Website
After adding the new inbound rule and saving it, launch the webserver with the public IP address from the
web browser.
http://<WebserverIP or FQDN>
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
4 | P a g e
Install – PHP, PHP-MySql
The next step is to install packages “php and php-mysql”, to install these packages run the command;
yum install php php-mysql -y
Validate PHP Installation
Next, we will create a php information page, in the DocumentRoot of httpd; run the command
cd /var/www/html
vi phpinfo.php
To test php is working, In the vi editor the text type “i” and then copy and paste below line, save and exit
the file “phpinfo.php”.
<?php phpinfo() ?>
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
5 | P a g e
Launch PHP Info Webpage
After adding the new webpage and text “phpinfo.php”; restart the httpd service and launch the webpage
“phpinfo.php” in the web browser. Php and MySQL version information should be populated in the
webpage as shown in the below screenshot.
systemctl restart httpd.service
http://<WebserverIP or FQDN>/phpinfo.php
PHP Version and libraries that are configured and enabled information will be displayed in this page
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
6 | P a g e
Install – Database Server
The next step is to install mariadb database server. Mariadb is an in-line replacement for the MySQL
Server.
Check Package – Mariadb Server
Before you install the mariadb server package on the host, check whether the package is already installed,
to check run the command.
rpm -qa | grep mariadb-server
rpm -qa | grep mysql-server
Install Package – mariadb Server
Next step, in order to install the mariadb server package on the host, to check run the command;
yum install mariadb-server -y
Enable – Service mariadb
systemctl list-unit-files | grep mariadb.service
After installation, the next step is to enable the service to start the service by default at multi-user
Runlevel, run the command;
systemctl enable mariadb.service
If the service is disabled which is default setting, it create a new symbolic link in the folder “multi-
user.target.wants” for the service.
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
7 | P a g e
Start – Service mariadb
When the mariadb server is installed database service does not start by default. You can check the status
of the mariadb service and to then start the service, run the commands below, to know status and start
the service respectively.
systemctl status mariadb.service
systemctl start mariadb.service
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
8 | P a g e
Create Database – blog
Next step after starting the database service is to create the database named “blog”, run the command;
mysqladmin -uroot create blog
Connect Database – blog
After creating the database, to ensure the database has been created, we will connect to the database,
run the command;
mysql -uroot -Dblog -s
Note: We are connecting to database in silent mode.
Securing Mariadb – Database
One of the most important step after installing Mariadb database server is the securing it. To secure it
run the command;
mysql_secure_installation
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
9 | P a g e
Securing Mariadb – Login Password
When mariadb server is installed, password is not configured or set for the root user, hence we in this
step press enter.
Enter current password for root (enter for none): Press enter key for none
Securing Mariadb – Confirm Password Change
Next step is to confirm the root password change, to continue the password change press “Y” and press
enter.
Set Root password? [Y/n]: Y
Securing Mariadb – Set New Password
The next step is to set the new password and re-enter the new password again. After confirming the new
password. The root password will be set and privilege tables will be reloaded.
New Password: Enter your new password
Re-enter new password: Re-enter your new password again
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
10 | P a g e
Securing Mariadb – Remove Anonymous User
Next step is to remove anonymous user access, this option will secure the database by allowing access to
the database wherein their user account created in the database, enter “Y” to revoke anonymous users
access.
Remove anonymous users? [Y/n]: Y
Securing Mariadb – Disallow root Login Remotely
The next step is to restrict access to root user from a remote system. This step will help database
administrator to login the server directly and only then login with “root”. Database Admin’s who to login
will from localhost only.
Disallow root login remotely? [Y/n]: Y
Securing Mariadb – Remove test Database and Access
In this step you will remove test database and the privileges for the “test” database.
Remove test database and access to it? [Y/n]: Y
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
11 | P a g e
Securing Mariadb – Reload Privilege Tables
Remove test database and access to it? [Y/n]: Y
Install WordPress
In this section we will navigate through the steps for download, installing and configuring wordpress.
Download Package
Next step is to download wordpress package from the internet, to download run the commands below, if
wget is not installed, you can utilize curl utility to download the package.
cd /tmp
curl -OL http://wordpress.org/latest.tar.gz
or
wget http://wordpress.org/latest.tar.gz
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
12 | P a g e
Extract Package
Next step is to extract the wordpress package that was downloaded from the internet and list the contents
after extracting to the DocumentRoot folder. Apache httpd service DocumentRoot by default is
configured as “/var/www/html” folder, run the command below to extract and verify the extraction.
tar -zxf latest.tar.gz -C /var/www/html/
ls -l /var/www/html/
Configure Wordpress
The next phase is to configure wordpress as the requirement, we will first rename the folder as “blog”,
configure database for the blog.
Rename Folder
After extracting the content, next step is to rename the “wordpress” folder as per your need, in this case
we will rename it as “blog”.
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
13 | P a g e
Rename Sample Configuration File
The next step is to rename the sample configuration file to “wp-config.php”, where in we will configure
database parameters for the blog website, run the below commands.
cd blog
mv wp-config-sample.php wp-config.php
Configure Database Parameters
The next step is to configure database parameters, to modify database attribute values, open “wp-
config.php” in editor, modify the below database connectivity attribute values. After modifying values
save and exit the file.
Attribute Name Default Value Modified Value
DB_NAME database_name_here blog
DB_USER username_here blog
DB_PASSWORD password_here blog
DB_HOST localhost localhost
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
14 | P a g e
WordPress Portal – Start Page
Next step is to launching the website, access the URL from the browser, welcome page is displayed.
http://54.165.245.172/blog/
WordPress Portal – Install WordPress
After launching the website, you need to configure administrator’s profile, fill below fields and click on
“Install WordPress” button.
Site Title Set Wordpress Site Title
Username Set Wordpress administrator username
Password Set Wordpress administrator password
Your E-Mail Set Wordpress administrator’s email ID
Privacy Set Privacy option
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
15 | P a g e
WordPress Portal – Login
After successful installation of “WordPress”, click on “Log In” button.
WordPress Portal – Administrator Login
Enter the administrator username and password set earlier and click on “Log In” button.
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
16 | P a g e
WordPress Portal – Dashboard
After login into the portal with administrator user, Portal’s Dashboard will be displayed.