Wordpress Checklist / by Joseph Palumbo

It's been a while since I played with Wordpress. It took me a while to remember/relearn how to setup WordPress on a server. Rather than having to go through that again, I'm posting a checklist of how I did it. 

For information purposes, I'm using a Digital Ocean Droplet with 1GB of RAM in the SFO data center. This droplet will run $10/month. I found that MariaDB was running out of memory on the $5/month Droplets, so I don't suggest them.

Install Apache

yum install httpd // installs Apache

systemctl start httpd.service // starts Apcahe

curl localhost // confirms Apache is running

systemctl enable httpd.service // start Apache on boot

Install MariaDB/MySQL

yum install mariadb-server mariadb // installs MariaDB

systemctl start mariadb // starts MariaDB

mysql_secure_installation // runs security script

systemctl enable mariadb // start MariaDB on boot

Install PHP

yum install php-mysql php // installs PHP

systemctl restart httpd.service // restarts Apache to PHP takes effect

yum list installed | grep php // test for PHP install

Install FirewallD

yum install firewalld // installs FirewallD

systemctl start firewalld.service // starts firewall service

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

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

firewall-cmd --reload // restarts firewall

Creating Apache Virtual Host

mkdir -p /var/www/example.com/public_html // creates DocRoot directory

chown -R $USER:$USER /var/www/example.com/public_html

chmod -R 755 /var/www // sets correct permissions on /var/www directory

Insert a test page if you want to.

mkdir /etc/httpd/sites-available // dir to keep our vhosts

mkdir /etc/httpd/sites-available // dir to hold symbolic links to vhosts we want to publish

echo "IncludeOptional sites-enabled/*.conf" >> /etc/httpd/conf/httpd.conf // inserts a directive at the bottom of the Apcahe configueration file

vim /etc/httpd/sites-available/example.com.conf // creates a vhost configuration file in the sites-available dir

Add this to the vhost configuration file:
<VirtualHost *:80>
ServerAdmin webmaster@your_domain.com
DocumentRoot /var/www/example.com/public_html
ServerName example.com ServerAlias www.example.com ErrorLog /var/log/httpd/example.com-error_log CustomLog /var/log/httpd/example.com-access_log combined

<Directory /var/www/html/example.com/public_html>
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride All
Require all granted

ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/example.com.conf // enables the virtual host

systemctl restart httpd.service // restarts Apache

Setting up the Wordpress Database

CREATE DATABASE [database name];

CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON [database name].* to 'user'@'localhost' WITH GRANT OPTION;

Download Wordpress

wget https://wordpress.org/latest.tar.gz // should be run inside dir where Wordprss should be installed

tar -zxvf latest.tar.gz // untars wordpress download

mv wordpress/* . // moves all the wordpress files up one directory

Add the correct values to wp-config.php.

Add define('FS_METHOD', 'direct'); to the bottom of wp-config.php

chown -R apache:apache /var/www // make Apache the owner over /var/www

vim /var/www/example.com/public_html/.htaccess // create a .htaccess file

Add to the .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

systemctl resart httpd.service