Categories
Samuel Technology

Hosting wordpress on multiple Amazon EC2 instances

I just wanted to do a quick tutorial on a solution to a problem that I recently had.  We are hosting a wordpress site on 3 amazon EC2 instances, this was causing an issue where the local files of each server were getting out of sync when someone made an edit in the wordpress admin (installed a new plugin, uploaded an image ect….). This article is as much of a resource for future use for myself so please pardon the lack of polish.

 

Programs used:

cgwyn: http://cygwin.com/install.html

wamp server: http://www.wampserver.com/en/

I started by hosting the wordpress site locally on my wamp server.  I’m going to leave out how to setup wamp server, a great resource for that is (setting up wamp server).  Any changes/updates to the site are first made on the local dev environment and then with rsync are pushed to the 3 EC2 instances.  So lets get into the rsync setup and commands:

1.) Install cywyn (note make sure to install rsync and ssh packages)  Use the search bar in the top right and search rsync and ssh when installing, then make sure to click the + sign and click the actual package name so that the words “skip” are removed.

2.) create a sync file and save it as a shell file in C:\cygwin64\home\your-username\  The sync file I used is shown below, you will need to replace with your local computer info and remote server info:

rsync -avz /cygdrive/c/wamp/www/youre-file-name/ your-user-name@SERVER-IP:/path-to-your-public-html

3.) open up cgwyn and run the following commands:

    chmod +x your-file-name.sh

and then you can run

./your-file-name.sh

Thats it, if successful you will get asked if you trust the remote server (only on first login) and you will also need the remote server password