Create a new marketing site using wordpress

Create a new marketing site using wordpress

Stack

We use WordPress deployed via docker on elastic beanstalk for marketing sites. All these sites https://www.cashflowy.in/, https://www.asyncauto.com/, http://www.mralbert.in/, https://www.parsemonkey.com/ are hosted using this stack.

This is our stack:

  • WordPress
  • MySQL
  • Docker
  • S3
  • Amazon Linux
  • Elastic Beanstalk
  • Divi

Installation steps

Step 1: Fork our basic wordpress repo

The basic scaffolding for our setup can be found in this repo – https://github.com/asyncauto/wordpress. Fork this repo into a new repository. We typically rename this new repository to the name of the subdomain that we are setting up. This way it is easier to remember which repo is related to what. E.g. while setting up marketing page for Mr albert the name of the repo was – www.mralbert.in

Step 2: Create s3 repo

We use aws s3 for backing up wordpress plugins and themes. WordPress allows users to install plugins and themes via the UI. All these items will be stored on the server machine. We are designing our stack in such a way that the individual server machine is disposable. This means everything that wordpress writes to the server needs to be periodically synced with s3.

So ahead and create a bucket on s3. Preferred naming convention for easy identification – mralbert-wp-content.

Step 3: Modify s3 policy

You need to modify bucket policy. you can find it under permission->bucket policy.

The policy should be:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "beanstalk",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::411068173358:role/aws-elasticbeanstalk-ec2-role"
            },
            "Action": [
                "s3:Get*",
                "s3:List*",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::bucket-name/*",
                "arn:aws:s3:::bucket-name"
            ]
        }
    ]
}

replace bucket-name with the name of your bucket (eg mralbert-wp-content)

Step 4: Modify .ebextensions/wp.config

Feed in the right bucket name in the config

Step 5: Configure elastic beanstalk

  • Create an application on the beanstalk
  • Create an environment in that application
  • Eb init – in your terminal so that your code points to the right environment
  • Eb deploy to deploy the code

Step 6: Disable nginx on elastic beanstalk

wordpress comes with inbuit apache server. So the Nginx server in beanstalk environment is not required. From the Beanstalk UI, disable the Nginx server.

Step 7: Create a MySql DB

We use a common mysql db for all our wordpress sites as none of these databases are individually large. So using Table plus, we create a new db in the same mysql machine.

Step 8: Update Cloudflare

We use cloudflare for dns management among other things. On cloudflare setup the right dns configs. In this case – www.mralbert.in should point to the newly created beanstalk environment.

Step 9: Update wordpress site address settings

When wordpress is installed, the site address most likely will be the url of the beanstalk environment. You need to change that to the actual url that you configured via cloudflare. In this case, we changed it to https://www.mralbert.in

Step 10: Install Divi

Follow the instructions here to install divi – https://www.elegantthemes.com/documentation/divi/install-divi/

Alex J V
Posted on:
Post author

Leave a comment

Your email address will not be published. Required fields are marked *