Skip to content

Commit

Permalink
Merge pull request #22 from mitchmac/main
Browse files Browse the repository at this point in the history
Update master
  • Loading branch information
mitchmac authored Aug 11, 2023
2 parents 7af3315 + f9486cd commit 3a3e678
Show file tree
Hide file tree
Showing 1,018 changed files with 141,134 additions and 90,411 deletions.
40 changes: 20 additions & 20 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Run WordPress On Vercel, Netlify, or AWS
# Host WordPress On Vercel, Netlify, or AWS
WordPress hosting is silly. Serverless WordPress on Vercel, Netlify, or AWS Lambda.

| Vercel (recommended) | Netlify |
| --- | --- |
| [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmitchmac%2Fserverlesswp&env=DATABASE,USERNAME,PASSWORD,HOST&envDescription=Database%20credentials%20from%20PlanetScale%20or%20other%20host&envLink=https%3A%2F%2Fgithub.com%2Fmitchmac%2FServerlessWP%23setup-vercel-or-netlify&project-name=serverlesswp&repository-name=serverlesswp) | [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/mitchmac/serverlesswp) |
| Vercel (recommended) | Netlify | AWS with Serverless Framework |
| --- | --- | --- |
| [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmitchmac%2Fserverlesswp&env=DATABASE,USERNAME,PASSWORD,HOST&envDescription=Database%20credentials%20from%20PlanetScale%20or%20other%20host&envLink=https%3A%2F%2Fgithub.com%2Fmitchmac%2FServerlessWP%23setup-vercel-or-netlify&project-name=serverlesswp&repository-name=serverlesswp) | [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/mitchmac/serverlesswp) | ```npm install && serverless deploy```

## Project Goals
### Quick install video

✅ Maintaining servers for WordPress can be a pain. Serverless hosting should be less work.
[![](https://markdown-videos.vercel.app/youtube/A1HZB2OqpCY)](https://youtu.be/A1HZB2OqpCY)

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

✅ Deploying WordPress should be easy. Setup a database and try one of the links above.
✅ 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.

Expand All @@ -21,17 +23,19 @@ WordPress hosting is silly. Serverless WordPress on Vercel, Netlify, or AWS Lamb

✅ We can create a helpful community. [Share your successes, knowledge, ideas, or struggles](https://github.com/mitchmac/ServerlessWP/discussions) in the discussions.

## Install video
## Deploying ServerlessWP

[![](https://markdown-videos.vercel.app/youtube/A1HZB2OqpCY)](https://youtu.be/A1HZB2OqpCY)
**This is currently an experimental project and shouldn't be used when considerable security or stability is required, yet**

## Setup (Vercel or Netlify)
1. **Create a MySQL database** that can be accessed from Vercel or Netlify.

**This is currently an experimental project and shouldn't be used when considerable security or stability is required, yet**
The easiest way to do this is with [PlanetScale](https://planetscale.com/) 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, Netlify, or AWS.** One of the links above will get you started. You'll just need a GitHub account.

1. **Create a MySQL database** that can be accessed from Vercel or Netlify. The easiest way to do this is with [PlanetScale](https://planetscale.com/) 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:
If deploying to AWS with the Serverless Framework for the first time, check the [Serverless Framework docs](https://www.serverless.com/framework/docs/getting-started) to get up to speed and run ```serverless deploy``` when ready.

3. **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
Expand All @@ -45,17 +49,13 @@ For more information about creating environment variables, see [here for Vercel]

## 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```
- Plugins like [Cache-Control](https://wordpress.org/plugins/cache-control/) can enable CDN caching with the s-maxage directive and make your site super fast. Refer to [Vercel Edge Caching](https://vercel.com/docs/concepts/edge-network/caching) or [Netlfiy Cache Headers](https://docs.netlify.com/edge-functions/optional-configuration/#supported-headers)

## Project structure
- `netlify.toml` or `vercel.json` are where we configure ```/api/index.js``` to handle all requests
- [mitchmac/serverlesswp-node](https://github.com/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](https://www.serverless.com/framework/docs/getting-started))
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](https://github.com/mitchmac/ServerlessWP/discussions) or [e-mail Mitch](mailto:[email protected])

Expand Down
19 changes: 19 additions & 0 deletions util/upgrade-wp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

cd ..
mkdir temp
cd temp
wget https://wordpress.org/latest.zip
unzip latest.zip
cp ../wp/wp-config.php wordpress/
mkdir wordpress/wp-content/mu-plugins
cp ../wp/wp-content/mu-plugins/serverlesswp.php wordpress/wp-content/mu-plugins/
rm -rf wordpress/wp-content/plugins/akismet wordpress/wp-content/plugins/hello.php
rm -rf wordpress/wp-content/themes/twentytwentytwo wordpress/wp-content/themes/twentytwentyone
wget https://downloads.wordpress.org/plugin/amazon-s3-and-cloudfront.zip
unzip amazon-s3-and-cloudfront.zip
mv amazon-s3-and-cloudfront wordpress/wp-content/plugins/
rm -rf ../wp
mv wordpress ../wp
cd ..
rm -rf temp
4 changes: 2 additions & 2 deletions wp/readme.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ <h2>Migrating from other systems</h2>

<h2>System Requirements</h2>
<ul>
<li><a href="https://secure.php.net/">PHP</a> version <strong>5.6.20</strong> or greater.</li>
<li><a href="https://secure.php.net/">PHP</a> version <strong>7.0</strong> or greater.</li>
<li><a href="https://www.mysql.com/">MySQL</a> version <strong>5.0</strong> or greater.</li>
</ul>

<h3>Recommendations</h3>
<ul>
<li><a href="https://secure.php.net/">PHP</a> version <strong>7.4</strong> or greater.</li>
<li><a href="https://www.mysql.com/">MySQL</a> version <strong>5.7</strong> or greater OR <a href="https://mariadb.org/">MariaDB</a> version <strong>10.3</strong> or greater.</li>
<li><a href="https://www.mysql.com/">MySQL</a> version <strong>5.7</strong> or greater OR <a href="https://mariadb.org/">MariaDB</a> version <strong>10.4</strong> or greater.</li>
<li>The <a href="https://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">mod_rewrite</a> Apache module.</li>
<li><a href="https://wordpress.org/news/2016/12/moving-toward-ssl/">HTTPS</a> support.</li>
<li>A link to <a href="https://wordpress.org/">wordpress.org</a> on your site.</li>
Expand Down
4 changes: 2 additions & 2 deletions wp/wp-activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
*/
function do_activate_header() {
/**
* Fires before the Site Activation page is loaded.
* Fires within the `<head>` section of the Site Activation page.
*
* Fires on the {@see 'wp_head'} action.
*
Expand Down Expand Up @@ -120,7 +120,7 @@ function wpmu_activate_stylesheet() {

get_header( 'wp-activate' );

$blog_details = get_blog_details();
$blog_details = get_site();
?>

<div id="signup-content" class="widecolumn">
Expand Down
Loading

0 comments on commit 3a3e678

Please sign in to comment.