Rud5G / ServerlessWP

Unmaintained Proof of Concept!! WordPress as a static website generator on AWS Serverless

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

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.

About

Unmaintained Proof of Concept!! WordPress as a static website generator on AWS Serverless

License:MIT License


Languages

Language:JavaScript 89.0%Language:Shell 6.7%Language:Dockerfile 4.3%