These steps are based on CentOS Server 64-bit
- Download CentOS
- Install CentOS
- Configure CentOS
- Install WordPress
- Configure WordPress
- 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
- Load the computer with the DVD (created from the ISO) or VM with the ISO
- Select the language (English & English (United States) then click the “Continue” button.
- Select the “Network & Host Name”
- Network settings:
- 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
- Network settings:
- Select the “Date & Time”
- Date & Time settings:
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
- Date & Time settings:
- Select the “Installation Destination”
Up to your discretion or company requirements (for this guide I have made assumptions):- Partitioning: “Automatically configure partitioning.”
- 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.
- Partitioning: “Automatically configure partitioning.”
- Click on “Begin Installation”
- Click on “Root Password”
- Set and confirm the password
- Click on the “Done” button in the top left
- Set and confirm the password
- Click on “User Creation”
- Fill out the Full name and user name
- 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
- Fill out the Full name and user name
- Click on the “Finish Configuration” button in the bottom right
- Click on the “Reboot” button
- If you created a hard drive passphrase you will see something like this
- Once you see this command you are ready to configure CentOS for WordPress
Configure CentOS
- Login as root
- 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.
- Run Yum Update
yum -y update
- Install wget
yum -y install wget
- Install MariaDB
yum -y install mariadb-server mariadb systemctl start mariadb.service systemctl enable mariadb.service
Configure Security Settings
/usr/bin/mysql_secure_installation
- 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) - 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
- 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
- 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;
-
tar zxvf /var/www/serversetup/WordPress_`date +"%m-%d-%Y"`.tar.gz -C /var/www/serversetup
- 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
- Now go to http://(IP or Hostname)/ to finish the setup
- “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
- 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
- On the Plugins page, activate the Two Factor Auth plugin
- Click on the Settings link, by default all user types are required to use the two factor process
- Click on “Two Factor Auth” link just above the “Tools” menu link
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. - Select “Third party apps (Duo Mobile, Google Authenticator etc)”
- 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
- 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)”
- Click on “Save Changes” button.
- Log out of the site
- Log back in, type in your username and password then click on the “Log In” button
- Type in the six digit number on your phone app or that you recieved in your email
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
Last Updated on March 18, 2016
You must be logged in to post a comment.