I am in the middle of migrating my site out of my datacenter into Amazon Web Services and as a part of that I decided to build a WordPress site using the AWS reference architecture and best practices (more about that in a later post). I also plan on incorporating Linux more into my architecture as an excuse to finally dig into this OS that I’ve been avoiding for the twenty-plus years of my career as a “Windows guy”.
I’ll be using both the Amazon Linux flavor and Ubuntu 16 LTS as my web servers that will drive www.rainwalk.net, folding.rainwalk.net, gallery.rainwalk.net and forums.rainwalk.net but Ubuntu does not come with AWS utilities built in like Amazon Linux does, so I plan on baking my own Amazon Machine Image (AMI) to use as my baseline. Here are the steps I performed to build my base image:
I started off by increasing the SSH timeout because I’m lazy and hate logging into a server after a timeout:
sudo nano /etc/ssh/sshd_config
and add the following two lines at the end:
ClientAliveInterval 120
ClientAliveCountMax 720
Then restart the sshd service or reboot.
sudo /etc/init.d/ssh restart
When the server has come back up and/or you have logged back in, update the base image with all the latest Ubuntu patches and fixes.
sudo apt dist-upgrade -y
sudo apt update -y
sudo apt upgrade -y
Since the primary function of these servers will be as a part of an autoscaling group referencing a common file area, I want the Ubuntu NFS client installed by default.
sudo apt install nfs-common -y
I’ve missed this step before so I like to make sure that I verify that the nfs-common package is installed
sudo dpkg -l |grep -i nfs-common
Next install binutils, the GNU Binary Utilities. They are a set of programming tools for creating and managing binary programs and we’ll need them for compiling the EFS utilities below.
sudo apt install binutils
Next install stunnel. Stunnel is a SSL encryption wrapper for network services and is a requirement for accessing encrypted EFS instances.
sudo apt update
sudo apt install stunnel4
Now we get to download, compile and install AWS EFS utilities.
git clone https://github.com/aws/efs-utils
cd efs-utils
sudo ./build-deb.sh
sudo apt-get -y install ./build/amazon-efs-utils*deb
Lastly we install python and pip, which is used to install python packages. Since the AWS CLI is Python based, we need it.
sudo apt update
sudo apt install -y python python-pip
Then install the AWS Command Line Interface
pip install awscli --upgrade --user
And since we are here and have probably received a prompt, update PIP to the latest version.
pip install --upgrade pip
Presto! We are all set to shut down this instance and bake it into an AMI.