Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

CentOS – WordPress Install

Posted on January 27, 2016March 18, 2016 By David Kittell

These steps are based on CentOS Server 64-bit

  1. Download CentOS
  2. Install CentOS
  3. Configure CentOS
  4. Install WordPress
  5. Configure WordPress
  6. Backup/Restore MySQL Database

Download CentOS

First we must download the CentOS DVD image, it is recommended to download straight from the official CentOS site (https://www.centos.org/download/).
For this document we will use CentOS 64-bit Everything ISO downloaded from http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Everything-1511.iso

Install CentOS

  1. Load the computer with the DVD (created from the ISO) or VM with the ISO
  2. Select the language (English & English (United States) then click the “Continue” button.
    Install_001
  3. Select the “Network & Host Name”
    Install_002

    • Network settings:
      Install_002_Network
    • Set Ethernet (or other network) to on
    • Name the server in “Host name” text box, by default it will say localhost.localdomain
    • For now click on the “Done” button in the top left
  4. Select the “Date & Time”
    Install_002

    • Date & Time settings:
      Install_002_DateTime
      You may need to toggle the “Network Time” on to off and back on for the network time server to update connection

    • Select your region and City
    • Click on the “Done” button in the top left
  5. Select the “Installation Destination”
    Install_002
    Up to your discretion or company requirements (for this guide I have made assumptions):

    • Partitioning: “Automatically configure partitioning.”
      Install_002_DiskPartition_01
    • Encryption: “Encrypt my data”
      Type in and confirm passphrase and click on the “Save Passphrase” button.
      Click on the “Done” button in the top left to return to the previous screen.
      Install_002_DiskPartition_02
  6. Click on “Begin Installation”
  7. Click on “Root Password”
    Install_003

    • Set and confirm the password
      Install_003_Root
    • Click on the “Done” button in the top left
  8. Click on “User Creation”
    Install_003

    • Fill out the Full name and user name
      Install_003_CreateUser
    • OPTIONAL: Check the check box to “Make this user administrator”
    • OPTIONAL BUT SUGGESTED: Keep the check box checked for “Require a password to use this account”
    • Set and confirm password
    • Click on the “Done” button in the top left
  9. Click on the “Finish Configuration” button in the bottom right
    Install_003_Complete
  10. Click on the “Reboot” button
    InstallComplete
  11. If you created a hard drive passphrase you will see something like this
    Boot_PassPhrase
  12. Once you see this command you are ready to configure CentOS for WordPress
    CentOSlogin

Configure CentOS

  1. Login as root
  2. Install SSH
    yum -y install openssh-server openssh-clients
    

    With SSH now installed if you are on Windows it’s suggested you go to Putty and connect to do the rest.

  3. Run Yum Update
    yum -y update
    
  4. Install wget
    yum -y install wget
    
  5. Install MariaDB
    yum -y install mariadb-server mariadb
    systemctl start mariadb.service
    systemctl enable mariadb.service
    

    Configure Security Settings

    /usr/bin/mysql_secure_installation
    
  6. Install Apache2
    yum -y install httpd
    systemctl start httpd.service
    systemctl enable httpd.service
    

    Allow HTTP and HTTPS in CentOS Firewall

    firewall-cmd --permanent --zone=public --add-service=http 
    firewall-cmd --permanent --zone=public --add-service=https
    firewall-cmd --reload
    

    Test your Apache2 Installation
    Go to http://(IP or HostName)

  7. Install PHP
    yum -y install php
    systemctl restart httpd.service
    echo "<?PHP phpinfo() ?>" > /var/www/html/info.php
    yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
    systemctl restart httpd.service
    

    Test your PHP Installation
    Go to http://(IP or HostName)/info.php

Install WordPress

  1. Download the latest released version of WordPress
    mkdir /var/www/serversetup/
    wget --no-check-certificate http://wordpress.org/latest.tar.gz -O /var/www/serversetup/WordPress_`date +"%m-%d-%Y"`.tar.gz
    
  2. Create the database and a user for WordPress to use.
    For our purposes the values we use can be changed to suit your needs:

    • Database: Site1WPDB
    • Username: Site1WPUSR
    • Password: Site1WPUSRPWD
    mysql -h localhost -u root -p
    CREATE DATABASE IF NOT EXISTS Site1WPDB;
    CREATE USER 'Site1WPUSR'@'localhost' IDENTIFIED BY 'Site1WPUSRPWD';
    GRANT ALL ON Site1WPDB.* TO 'Site1WPUSR'@'localhost';
    FLUSH PRIVILEGES;
    Exit;
    
  3. tar zxvf /var/www/serversetup/WordPress_`date +"%m-%d-%Y"`.tar.gz -C /var/www/serversetup
    
  4. Configure WordPress
    For our purposes the values we use can be changed to suit your needs:

    • Database: Site1WPDB
    • Username: Site1WPUSR
    • Password: Site1WPUSRPWD
    cd /var/www/serversetup/wordpress
    cp wp-config-sample.php wp-config.php
    sed -i 's/database_name_here/Site1WPDB/g' wp-config.php
    sed -i 's/username_here/Site1WPUSR/g' wp-config.php
    sed -i 's/password_here/Site1WPUSRPWD/g' wp-config.php
    rm -f /var/www/html/info.php
    mv -v /var/www/serversetup/wordpress/* /var/www/html/
    cd /var/www/html
    echo '<IfModule mod_rewrite.c>' > .htaccess
    echo 'RewriteEngine On' >> .htaccess
    echo 'RewriteBase /' >> .htaccess
    echo 'RewriteRule ^index.php$ - [L]' >> .htaccess
    echo 'RewriteCond %{REQUEST_FILENAME} !-f' >> .htaccess
    echo 'RewriteCond %{REQUEST_FILENAME} !-d' >> .htaccess
    echo 'RewriteRule . /index.php [L]' >> .htaccess
    echo '</IfModule>' >> .htaccess
    groupadd www-data
    sudo usermod -a -G www-data wpadmin
    chown wpadmin:www-data -R /var/www
    
  5. Now go to http://(IP or Hostname)/ to finish the setup

    Image 42

    • “Site Title” is the title of the site
    • “Username” is the admin user that you will primary use for administration tasks
      Suggestion: Do not use admin, webmaster, administrator
    • “Password”, type your desired password
      If you do not have a strong password it will warn you but you can check a check box to allow the weak password – NOT RECOMMENDED
    • “Your E-mail” is the email address for the admin of the site, best to make this a distribution list of trusted individuals otherwise the email of the administrator account
    • “Privacy”, typically if the site is internal you want to uncheck the check box otherwise you want search engines to see you.
    • When ready click on the “Install WordPress” button
    • You are now ready to login

Configure WordPress

Two Factor Auth

This plugin is to add security to the WordPress site by requiring all users to use a two factor authentication so that simply having the password won’t let a potential hacker in.

Setup

  1. Install from http://(IP or Hostname)/wp-admin/plugin-install.php?tab=plugin-information&plugin=two-factor-auth&TB_iframe=true&width=772&height=799
  2. On the Plugins page, activate the Two Factor Auth plugin
  3. Click on the Settings link, by default all user types are required to use the two factor process
  4. Click on “Two Factor Auth” link just above the “Tools” menu link

    Image 43

    There are two delivery types; Email and Third Party Apps
    Note: Whether you choose Email or Third Party Apps the users will initially get emailed their one time code when they login for the first time.

  5. Select “Third party apps (Duo Mobile, Google Authenticator etc)”
  6. With your phone scan the QR-Code on the screen using one of the tested apps
    • Android – Duo Mobile or Google Authenticator
    • iPhone – Duo Mobile
    • Windows Phone – Windows Authenticator
  7. Scroll to the bottom of the page to find “Advanced”, click on “Show advanced info” it is suggested to keep it on “TOTP (time based)”
  8. Click on “Save Changes” button.
  9. Log out of the site
  10. Log back in, type in your username and password then click on the “Log In” button

    Image 44
  11. Type in the six digit number on your phone app or that you recieved in your email

    Image 45

Support

If you forget/lose the authentication codes you need to terminal into the server and run the disable script.

mv /var/www/html/wp-content/plugins/two-factor-auth/ /var/www/html/wp-content/plugins/two-factor-auth_disabled/

Once you are able to get back in run the enable script

mv /var/www/html/wp-content/plugins/two-factor-auth_disabled/ /var/www/html/wp-content/plugins/two-factor-auth/

Backup/Restore MySQL Database

The purpose of this step is to have a quick repeatable command to backup and restore a database.
Log in a your username (not root) and run this command
For our purposes the values we use can be changed to suit your needs:

  • Database: Site1WPDB
  • Username: Site1WPUSR
  • Password: Site1WPUSRPWD
echo '[mysqldump]'> ~/.my.cnf;
echo 'user=Site1WPUSR'>> ~/.my.cnf;
echo 'password=Site1WPUSRPWD' >> ~/.my.cnf;
chmod 0600 ~/.my.cnf
mysqldump -u Site1WPUSR Site1WPDB > ~/WordPress_DB_Backup_`date +"%m-%d-%Y_%I-%M-%S"`.sql
tar -zcvf WordPress_Site_Backup_`date +"%m-%d-%Y_%I-%M-%S"`.tar.gz /var/www/html

Make sure you modify the date of the file to what you want to restore from.

mysql -u Site1WPUSR Site1WPDB < ~/WordPress_DB_Backup_08-27-2015.sql
Originally Posted on January 27, 2016
Last Updated on March 18, 2016
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

CentOS Code UNIX UNIX Shell Scripts WordPress

Post navigation

Previous post
Next post

Related Posts

Get Division Dates

Posted on June 24, 2013October 26, 2015

SELECT DIVISION_NBR ,YMDEFF ,YMDEND ,YMDTRANS FROM division_span WHERE rownum < 10 AND division_nbr = ‘<div_number_to_search>’ Originally Posted on June 24, 2013Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development)…

Read More

SQL Connection Test

Posted on December 3, 2013October 26, 2015

Imports System.Data.SqlClient Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim SqlConn As New SqlConnection Dim SqlConnStr As String = "Server=<Server Name/IP>;Database=<Database Name>;Integrated Security=True" If SqlConn.State = ConnectionState.Closed Then SqlConn.ConnectionString = SqlConnStr Try SqlConn.Open() MessageBox.Show("Succsessfull DB Connnection", "DB Connection Test", MessageBoxButtons.OK, MessageBoxIcon.Information) Catch…

Read More

Excel – Find Comma Replace With LineBreak

Posted on August 11, 2015October 26, 2015

Selected the range of cells you need to replace. Go to Home > Find & Select > Replace or Ctrl + H Find what: , Replace with: CTRL + SHIFT + J Click Replace All Somehow CTRL + SHIFT + J is registered as a linebreak. Reference: http://stackoverflow.com/questions/14856501/substitute-a-comma-with-a-break-link-in-a-cell Originally Posted…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes
 

Loading Comments...
 

You must be logged in to post a comment.