Giter Club home page Giter Club logo

aws-serverless-wordpress's Introduction

AWS Serverless WordPress

Introduction

Please read the blog post for introduction and explanation. Dev.to: Best Practices for Running WordPress on AWS using CDK

WordPress Plugin Used

  • W3 Total Cache
  • WP Offload Media Lite
  • ElasticPress
  • Multiple Domain
  • HumanMade - AWS-XRay (Working on making it work...)

Architecture Diagram

Architecture Diagram

Deployment - (To be update)

Before getting started

Please make sure you have/are

  • Using bash
  • Node.js installed
  • NPM and Yarn installed
  • Installed and running Docker
  • Installed and configured AWS CLI
  • Installed the latest version of AWS CDK CLI

Please be notice, this stack only can deploy into us-east-1 0. You should have a public hosted zone in Route 53

  1. Initialize the CDK project, run make init
  2. Deploy the CDK Toolkit stack on to the target region, run cdk bootstrap aws://AWS_ACCOUNT_ID/AWS_REGION --profile AWS_PROFILE_NAME
  3. Copy the config.sample.toml and rename to config.toml
  4. Run make easy-rsa-init gen-cert import-cert to generate the certificate for the Client VPN
  5. Modify the configuration in config.toml
    [environment]
    account = "YOUR_AWS_ACCOUNT_ID" # Your AWS account ID
    
    [admin]
    allowIpAddresses = ["0.0.0.0/0"] #Your home/office public IPv4 address, if using a specific IP add /32 like 24.222.174.192/32
    
    #Both certificate ARN should create and get from the previous steps
    serverCertificateArn = "arn:aws:acm:us-east-1:YOUR_AWS_ACCOUNT_ID:certificate/xxxxxxxxxxxxxxxxxxxxxxxx"
    clientCertificateArn = "arn:aws:acm:us-east-1:YOUR_AWS_ACCOUNT_ID:certificate/yyyyyyyyyyyyyyyyyyyyyyyy"
    
    [database]
    username = "wordpress" #Database username
    defaultDatabaseName = "wordpress" #Default database name
    
    [domain]
    domainName = "example.com" #Your root domain name, useually is the domain name of the created public hosted zone in Route 53
    hostname = "blog.example.com" #Your desire hostname for the WordPress
    alternativeHostname = ["*.blog.example.com"]
    
    [contact]
    email = ["[email protected]"] #Email address for notify any in-compliance event in AWS Config
  6. Run make deploy profile=YOUR_AWS_PROFILE_NAME
  7. After the CloudFormation stack deployed, open the Session Manager in System Manager, and open a session to the created bastion host. Then run the following command. (The version of WordPress plugin may NOT be latest)
    sudo su -
    cd /mnt/efs/wp-content/plugins &&\
    curl -O https://downloads.wordpress.org/plugin/w3-total-cache.0.15.1.zip &&\
    curl -O https://downloads.wordpress.org/plugin/amazon-s3-and-cloudfront.2.4.4.zip &&\
    curl -O https://downloads.wordpress.org/plugin/elasticpress.zip &&\
    curl -O https://downloads.wordpress.org/plugin/multiple-domain.zip &&\
    curl https://codeload.github.com/humanmade/aws-xray/zip/1.2.12 -o humanmade-aws-xray-1.2.12.zip &&\
    unzip '*.zip' &&\
    rm -rf *.zip
  8. After the installation, go to the webpage and setup the database connection and plugin configuration. For the hostname of Memcached or MySQL, please check the output in CloudFormation stack.
  9. For Mutiple Domain plugin, please enter blog.example.com and admin.blog.example.com these 2 hostname.

References

https://aws.amazon.com/tw/blogs/devops/build-a-continuous-delivery-pipeline-for-your-container-images-with-amazon-ecr-as-source/ https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/blue-green.html

https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-ecs-ecr-codedeploy.html#tutorials-ecs-ecr-codedeploy-cluster https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-networking.html https://stackoverflow.com/questions/56535632/how-do-i-link-2-containers-running-in-a-aws-ecs-task

https://github.com/Monogramm/docker-wordpress https://github.com/fjudith/docker-wordpress https://github.com/humanmade/aws-xray

https://pecl.php.net/package/memcached https://pecl.php.net/package/APCu

https://stackoverflow.com/questions/54772120/docker-links-with-awsvpc-network-mode

https://www.mgt-commerce.com/blog/aws-varnish-auto-scaling-magento/

https://downloads.wordpress.org/plugin/w3-total-cache.0.15.1.zip https://downloads.wordpress.org/plugin/wp-ses.1.4.3.zip https://downloads.wordpress.org/plugin/amazon-s3-and-cloudfront.2.4.4.zip https://downloads.wordpress.org/plugin/elasticpress.zip

aws-serverless-wordpress's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.