WordPress hosting is silly. Serverless WordPress on Vercel, Netlify, or AWS Lambda.
Vercel (recommended) | Netlify | AWS with Serverless Framework |
---|---|---|
npm install && serverless deploy |
✅ 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. Vercel, Netlify, AWS, & PlanetScale have free tiers.
✅ 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.
This is currently an experimental project and shouldn't be used when considerable security or stability is required, yet
- 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
.
- Deploy this repository to Vercel, Netlify, or AWS. One of the links above will get you started. You'll just need a GitHub account.
If deploying to AWS with the Serverless Framework for the first time, check the Serverless Framework docs to get up to speed and run serverless deploy
when ready.
- Update the environment variables for your project in Vercel or Netlify with the database credentials from PlanetScale or wherever you host the MySQL database. The WordPress config file
wp-config.php
uses these values to connect to the database. 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.
- (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
- WordPress and its files are in the
/wp
directory. You can add plugins or themes there in their respective directories inwp-content
- Plugins like Cache-Control can enable CDN caching with the s-maxage directive and make your site super fast. Refer to Vercel Edge Caching or Netlfiy Cache Headers
netlify.toml
orvercel.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 WordPressresponse
object there.
Need help getting ServerlessWP installed? Start a discussion or e-mail Mitch
- Just using ServerlessWP and reporting any problems you experience is a fantastic way to help!
- Spread the word! Let's try to make WordPress hosting better.
GNU General Public License v3.0