Building a WordPress site in AWS

Here are the steps I used to get this site up and running.

Besides having a blog I wanted to use this site as a chance to get more familiar with a lot of technologies that I haven’t had a chance to be exposed to in my current position. To that end I am going to host the site using an instance of Ubuntu on the Amazon Web Services free tier. For the majority of the setup I used some great guides over at Digital Ocean. I will just reference those and then talk about specific issues I ran into, I don’t see any need to redo all the great work they have already done for me.

Setting up the host and getting connected

  • I signed up for the AWS free-tier and launched a new instance of Ubuntu 14.04.
  • During the process you will have to download a new key pair (.pem). I usually save this to some cloud storage like DropBox so I can always have access if I need it.
  • Open up Puttygen (C:Program Files (x86)PuTTYputtygen.exe) and click File > Load Private Key and then File >Save PrivateKey.
  • Save the .ppk file to the same folder.
  • Check back on your EC2 dashboard and note the Public IP and Security Group name.
  • While you are in your dashboard click Security Groups on the left hand menu.
  • Click on the Security Group you noted previously.
  • Click the inbound tab and then click Edit.
  • Add rules for HTTP and HTTPS and leave the source as Anywhere.
  • Open up Putty (C:Program Files (x86)PuTTYputty.exe) and enter the Public IP you noted previously in the host name field.
  • In the left-hand menu click on Data and enter ubuntu for the Auto-login username.
  • In the left -hand menu expand SSH and click on Auth.
  • Load the .ppk you just created under Authentication Parameters.
  • In the left-hand menu click on Session and enter a name under Saved Sessions and click save.
  • Click Open and you should be connected to your Ubuntu instance.

Updating the host and installing

As I said above I mostly just stuck to the Digital Ocean guides since they were written for the same distro I am using (ubuntu 14.04) and they also covered all the basics which I needed at this point. The ones I used were How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu, How To Install WordPress on Ubuntu 14.04, and How To Configure Secure Updates and Installations in WordPress on Ubuntu in that order. Just following along all the steps worked out pretty much perfectly for me. The first two guides are actually enough to get you up and running but I found out pretty quickly that you need to setup secure updates in order to be able to install new themes and plugins. I probably could have gotten away with FTP but I am trying to keep this site as secure as possible since this is all a learning exercise for me.

I did run into a few issues that I will go into further. First of all the guides ask you to run apt-get a lot. I went through and complied all of the requests to install a package so they can be run as a one liner.

sudo apt-get install apache2 mysql-server libapache2-mod-auth-mysql php5-mysql php5 libapache2-mod-php5 php5-mcrypt php5-gd libssh2-php php5-dev libssh2-1-dev

Also if you are tempted to change the usernames along the way be my guest but just make sure to keep track off all of the changes you make because these guides are cumulative and I had it come back to bite me a few times, especially when I was setting up the new users in the secure updating guide.

Once I had the website up and running and had chosen my theme I installed the Askimet plugin to control spam and the SyntaxHighlighter Evolved plugin to create code blocks since I plan on posting a fair bit of powershell scripts to this page. I also recommend going through the site settings and configuring things to your liking.

The next problem I ran into had to do with permalinks. Whenever I tried to use a permalink I was getting a 404 error. after some troubleshooting it turns out I had to enable mod_rewrite in apache. This site was where I ended up and after enabling the rewrite module and restarting apache I was all set.

sudo a2enmod rewrite
sudo service apache2 restart

Finally I ran into an issue where I couldn’t upload pictures to the site. It turns out during the secure updates configuration the Digital Ocean guide has you give ownership of everything to the wp-user user. Well this breaks content uploading so you have to go back and give www-data ownership on the /var/www/html/wp-content/uploads/ directory.

sudo chown -R www-data:www-data /var/www/html/wp-content/uploads/

Still on my ToDo list for this site is configuring SSL and forcing all admin logons to use it and configuring a script to backup the site to my DropBox.

I hope this was a help to you, as I get more comfortable using Linux I know that all in one guide such as these can be a big help. As always if you run into any issues Google is your friend, it was certainly mine.