Skip to content
/ ServerlessWP Public template
forked from mitchmac/ServerlessWP

Host WordPress sites on Vercel, Netlify, or AWS Lambda

License

Notifications You must be signed in to change notification settings

dgecheverria/ServerlessWP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run WordPress On Vercel, Netlify, or AWS

WordPress hosting is silly. Serverless WordPress on Vercel, Netlify, or AWS Lambda.

Vercel (recommended) Netlify
Deploy with Vercel Deploy to Netlify

Project Goals

✅ Maintaining servers for WordPress can be a pain. Serverless hosting should be less work.

✅ Small WordPress sites shouldn't cost much (or anything) to host.

✅ Deploying WordPress should be easy. Setup a database and try one of the links above.

✅ WordPress plugins and themes save time and should be extensively supported.

✅ Edge caching can give us blazing fast websites.

✅ We can reduce the carbon footprint of WordPress websites.

✅ We can create a helpful community. Share your successes, knowledge, ideas, or struggles in the discussions.

Install video

Setup (Vercel or Netlify)

This is currently an experimental project and shouldn't be used when considerable security or stability is required, yet

  1. Create a MySQL database that can be accessed from Vercel or Netlify. The easiest way to do this is with PlanetScale which has a free tier to get started. When using PlanetScale, make sure your database's region matches the region that Vercel or Netlify will use. This is usually us-east-1.
  2. Deploy this repository to Vercel or Netlify. One of the links above will get you started. You'll just need a GitHub account.
  3. Update the environment variables for your project in Vercel or Netlify with the database credentials. These are used by wp-config.php. The environment variables are:
  • DATABASE
  • USERNAME
  • PASSWORD
  • HOST

For more information about creating environment variables, see here for Vercel and here for Netlify. Remember to redeploy your project after updating the environment variables if you update them after initially deploying your project.

  1. (optional, can be done later) File and media uploads can be enabled using the included WP Offload Media Lite for Amazon S3 plugin. S3 setup details can be found here. The wp-config.php file is setup to use the following environment variables for use by the plugin:
  • S3_KEY_ID
  • S3_ACCESS_KEY

Customizing WordPress

  • WordPress and its files are in the /wp directory. You can add plugins or themes there in their respective directories in wp-content

Project structure

  • netlify.toml or vercel.json are where we configure /api/index.js to handle all requests
  • mitchmac/serverlesswp-node is used to run PHP and handle the request
  • You can modify the incoming request through the event object in api/index.js. You can also modify the WordPress response object there.

Setup (Serverless Framework)

  1. Install and setup the serverless framework (docs)
  2. Clone the repository and run serverless deploy to confirm that the Lambda is created
  3. Like step 2 above, create a MySQL database and update the environment variables. They can be updated in the serverless.yml file and then run serverless deploy again.

Getting help

Need help getting ServerlessWP installed? Start a discussion or e-mail Mitch

How can you help?

License

GNU General Public License v3.0

About

Host WordPress sites on Vercel, Netlify, or AWS Lambda

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 67.1%
  • JavaScript 23.8%
  • CSS 8.3%
  • Svelte 0.4%
  • SCSS 0.4%
  • HTML 0.0%