This was copied from the following guides:
It’s a work in progress. 🚧
This is a template repository for running Wordpress on Render.
It uses the official MySQL and Wordpress Docker images, along with Render’s Web Services, Private Services, and Disks.
In this guide:
-
Use this template to generate a new repository for WordPress in your GitHub account.
-
Change the name of the default branch in your repository. For example:
main
-
Make any changes you wish to your copy of the Dockerfile(s) or render.yaml. For example, you may want to change the region and replace
myappname
with the name of your application. -
Deploy your repository to Render as a Blueprint.
As part of the deployment process, you’ll be prompted for an Amazon Web Services (AWS) account,
for storing database backups.
Environment variable | Value |
---|---|
AWS_REGION | Choose the AWS region closest to the region of your database. For example, a MySQL instance in Render's Oregon region would use us-west-2 for the AWS Region US West (Oregon). |
S3_BUCKET_NAME | Choose a globally unique name for your bucket. For example <my-amazon-username>-<my-app-name>-render-mysql-backups . The name must follow Bucket naming rules. |
AWS_ACCESS_KEY_ID | Enter the Access key ID (AKIAXXXXXXXXXXXXXXXX ) for a new user in your Amazon Web Services account. |
AWS_SECRET_ACCESS_KEY | Enter the secret access key for a new user in your Amazon Web Services account. |
After deploying, MySQL and WordPress will take a few minutes to start.
Your WordPress instance will be available on your .onrender.com
URL as soon as the deploy is live.
WordPress may fail to deploy on the first try. You can use the “Manual Deploy” button in the Render Dashboard to deploy again. The second try usually succeeds.
You can then configure WordPress by going to https://your-subdomain.onrender.com
.
See the official guide on Render, for more tips: https://render.com/docs/deploy-wordpress
Render supports custom domains: https://render.com/docs/custom-domains
If you add a custom domain, you may also want to change the domain on the settings page of your WordPress Admin Dashboard.
You can transfer files to and from your WordPress Web Service.
You can connect to MySQL from other applications running in your Render account using the name and port for your Private Service. For example, you can a create a Web Service to manage your MySQL database using Adminer. See Render’s Adminer Deployment Guide for details.
You can also use SSH or the shell in your Render Dashboard to connect to your database.
Learn more about connecting to MySQL.
mysql -h localhost -D $MYSQL_DATABASE -u $MYSQL_USER --password=$MYSQL_PASSWORD
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 92
Server version: 8.0.29 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
The included mysql Dockerfile runs MySQL 8. You can change this to a different version, by editing your copy of the Dockerfile.
Relying on a disk snapshot to restore a database is not recommended. Restoring a disk snapshot will likely result in corrupted or lost database data.
Using a database’s recommended backup tool (for example: mysqldump) is the recommended way to backup and restore a database without corrupted or lost data.
This repository includes a Cron Job for backing up your MySQL database to Amazon S3. To use this, you will need an Amazon Web Services (AWS) account.
It’s a good idea to make a full backup of your WordPress files too: https://jetpack.com/blog/how-to-back-up-your-wordpress-site/
You can follow these steps to create credentials with AWS IAM, to enable working with Amazon S3.
-
Open the AWS console and navigate to the IAM service. Open the Users view and select the
Add Users
button. -
Enter a descriptive username, such as
<database name>-render-mysql-backup-cron
. -
For
Select AWS credential type*
selectAccess key - Programmatic access
. -
Select the
Next: Permissions
button to move to theSet Permissions
view. -
In the
It's possible to use finer-grained policies to authorize the Cron Job. Render recommends Litestream's guide if you'd like to further lock down permissions.Set Permissions
view, selectAttach existing policies directly
and search forAmazonS3FullAccess
. Check the box to selectAmazonS3FullAccess
. -
Skip through the next two views with the
Next
buttons to move to theReview
view. Confirm the details of your user. -
Select the
Create User
button. -
Record the access key ID (
AKIAXXXXXXXXXXXXXXXX
) and the secret access key.
By default, the Cron Job will run the backup daily at 3 a.m. UTC. You can change the time and frequency by modifying the Cron Job's schedule
in your copy of the render.yaml file.
-
View the newly created Cron Job and wait for the first build to finish.
-
Select the
Trigger Run
button and wait for the job to finish with aCron job succeeded
event. -
Verify the backup by inspecting the contents of your S3 bucket.
-
Download the required
.sql.gz
file from your S3 bucket. -
Unzip the backup file.
Replacebackup-file.sql.gz
with the name of your backup file.gzip -d backup-file.sql.gz
-
Connect to your MySQL service with SSH or the shell in your Render Dashboard.
If your MySQL service is offline and can’t be restarted, you may need to deploy a new MySQL service and restore your database there instead.
-
Transfer the backup file to your MySQL service.
-
Use your backup file with the MySQL Command-Line Client.
Here’s an example command that will connect to your database and run the SQL statements in your backup file.
Replace backup-file.sql
with the name of your backup file.
mysql \
-h localhost \
-u $MYSQL_USER \
--password=$MYSQL_PASSWORD \
$MYSQL_DATABASE \
< backup-file.sql
The aws
CLI tool requires additional configuration when uploading large files to S3. If your compressed backup file exceeds 50 GB, add an --expected-size
flag in the the upload_to_bucket
function in backup.sh
.
You may have an error with your IAM user if your Cron Job fails and you see an error message similar to:
An error occurred (SignatureDoesNotMatch) when calling the CreateBucket operation:
The request signature we calculated does not match the signature you provided.
Check your key and signing method.
Check over the Create AWS Credentials instructions.