Monday, 16 October 2017

Wordpress AWS Part 7 - Deploy Wordpress

Wordpress AWS Part 7 - Deploy Wordpress


An overview of the process.
  • Decide of the domain name of the Wordpress, and make it point to the Beanstalk application. In this example, we will be using the name "aws.testquek.tk".
  • Deploy Vanilla Wordpress.
    • Include the ".ebextensions" folder to automount and symlink the EFS.
    • Create and edit "wp-config.php" to include the database details, and also with the keys and salts.
    • Change table prefix (optional).
    • Deploy (we will be calling the zip file "wordpress-4.8.2-v1.zip").
    • Run the installer.
  • Modify Wordpress to make it work in AWS.
    • SSH in the EC2 instance, check and ensure that the EFS is mounted and sym-linked.
    • In EC2 instance, copy contents of "wp-content" folder into EFS, remove "wp-content" folder.
    • In EC2 instance, edit "wp-config.php" for new "wp-content" location.
    • Test (create post and upload pictures). If OK, proceed.
  • Deploy modified Wordpress.
    • At local computer, remove "wp-content" folder.
    • At local computer, edit "wp-config.php" for new "wp-content" location.
    • At local computer, add in ".htaccess" file.
    • Include the ".ebextensions" folder to automount and symlink the EFS.
    • Deploy (we will be calling the zip file "wordpress-4.8.2-v2.zip").
    • Test (check created post and uploaded pictures).

Let's get started.

Decide of the domain name of the Wordpress.


In this example, we are using the name "aws.testquek.tk". To make it point to the Beanstalk, we need to find out the URL of the application (screenshot in part 5), and then do a CNAME to it.

Deploy Vanilla Wordpress.


Extract Wordpress files in local computer.
Put in ".ebextensions" folder (that will auto-mount and symlink the EFS).
Create and edit "wp-config.php" to use the RDS and for the keys and salts.
Create the zip file.
Deploy the zip file.
Run the installer by going to http://aws.testquek.tk.
Notice that the installer does not ask for database details. We already specified it in the wp-config.php.
Wordpress confirm installed. 

Modify Wordpress to make it work in AWS.


Ensure that the EFS is mounted and symlinked.
Anything in "/wpfiles" is in the EFS.
Copy contents of "wp-content" to EFS.
Remove "wp-content" folder.
Edit "wp-config.php" to use EFS.
Test create post with picture.
See location of picture.
Confirm that picture is in EFS.
Noticed that we have made a few changes while working in SSH, namely, removed "wp-content" folder, and edited "wp-config.php".
The Wordpress installation process also created a ".htaccess" file. It would be a good idea to get the contents of that ".htaccess" file now, as we need to create it later in the local computer.
All changes will be lost when Beanstalk re-creates the EC2 instance for whatever reason. So we need to edit the copy in our local computer, and create a newer version of the application.

Deploy modified Wordpress.


Local "wp-content" folder deleted.
Edit local "wp-config.php".
Create ".htaccess" file. Create the zip file.
Deploy.
Deploy success.
Uploaded picture is still available.
We took the original Wordpress, made some changes, so that it can work in an AWS environment properly.

Important Note
Wordpress often modifies the files ".htaccess" and "wp-config.php", especially when installing plugins. It is important to be aware of these changes, so that the same changes can be done in the local copy, and be re-deployed as a newer version.


Part 1 - Overview
Part 2 - RDS
Part 3 - EFS
Part 4 - Key Pairs
Part 5 - Beanstalk
Part 6 - ebextensions Folder
Part 7 - Deploy Wordpress
Part 8 - 4000 Concurrent Connections