Giter VIP home page Giter VIP logo

serverlesswp's Introduction

ServerlessWP

WordPress as a static website generator on AWS Serverless

Many WordPress websites could be replaced by static HTML. Static websites are cheaper, faster, and more secure to host. Why not use WordPress as a static website generator so we can still edit content via our web browser and use many of the great WordPress themes and plugins?

Fast & secure static website hosting

Easy browser based content management

Compatible with most WordPress themes and many plugins

WordPress backend isolated from the web

Pay only for what is used

Interested in a similar approach to WordPress on Serverless? Checkout Pressless for a tool to migrate an existing WordPress site to run on AWS.

Learn more

ServerlessWP enables hosting the backend WordPress installation, where we add and manage content, on AWS Serverless products so that we don't have to worry about maintaining a server. Serverless means we only pay for what we use, and most websites don't get edited too often. Combined with AWS free tier offerings, we can host the backend for next to nothing in cost.

ServerlessWP puts Basic Authentication in front of the backend WordPress installation to limit its exposure to bots and other sources of unwanted traffic.

The backend WordPress website is crawled to generate the static website. The static HTML is uploaded to Amazon S3 for storage and hosting. AWS CloudFront is used to provide CDN hosting and SSL for the public-facing website.

A typical blog will cost around $1 per month to run (mainly depending on CloudFront data transfer and database uptime for content management). The RDS-based MySQL database for WordPress will shut down automatically after 2 hours of inactivity to reduce costs, since it is not necessary for the static frontend.

Disclaimer: This is a proof of concept! Breaking changes may be made if/when Aurora Serverless becomes a preferable database option versus the current RDS usage.

Installation

  1. Install the Serverless Framework for AWS - Serverless installation guide
  2. Clone or download this repository
  3. Place necessary binary files in the "bin" directory.
    • This can be handled by running the "./build_bin.sh" script if you have Docker installed.
    • "php-cgi" and "wget" are the currently necessary binaries. They must be compiled to run in the Lambda environment.
    • The "./bin/lib" directory requires a library noted in bin/lib/readme.txt. It will be put in place if "./build_bin.sh" is used.
  4. Place a WordPress installation directly in the "wp" directory so that "index.php" is found in the root of "wp".
    • This can be handled by executing the "./build_wp.sh" script.
  5. Modify "wp-config.php" for ServerlessWP friendly configuration.
    • This is handled by the "./build_wp.sh" script if used.
    • Otherwise, use this wp-config-base.php as a guide.
  6. To handle file uploads in the WordPress backend, install the necessary WordPress plugins:
  7. Place any other WordPress themes or plugins in the respective wp-content directories like a standard WordPress installation.
  8. Edit serverless.yml
    • The "custom" section at the top of the file has variables that should be reviewed.
  9. Run "npm install"
  10. Run "severless deploy" -- may take 30-60 minutes for AWS to create the necessary resources the first time.
  11. Complete the WordPress installation by visiting the first URL in the "endpoints" output, this is the URL for the WordPress backend. It will look like endpoints: https://example.execute-api.us-east-1.amazonaws.com/dev/
  12. Login to WordPress and enable the ServerlessWP, Amazon Web Services, and WP Offload S3 Lite plugins.
  13. Point your domain's DNS at the created CloudFront distribution.

Authors

Acknowledgments

The following articles and repositories provided ideas, examples, and best practices for various parts of the project:

License

This project is licensed under the MIT License - see the LICENSE file for details.

serverlesswp's People

Contributors

mitchmac avatar

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.