Before you start, check out the Upsun demo app
and the main Getting started guide.
They provide all the core concepts and common commands you need to know before using the following materials.
Assumptions
There are many ways you can set up a WordPress site or Upsun project. The instructions on this page were designed based on the following assumptions:- You are building a Bedrock-based WordPress site using Roots.io Bedrock boilerplate.
- You have an existing Bedrock-based codebase or created a new Composer project using
roots/bedrockduring the Getting started guide. - You selected PHP as your runtime, and MariaDB as a service during the Getting Started guide. It’s also assumed that
while using the Getting Started guide you named the project
myapp, which you will notice is the top-level key in all configuration below.
1. Configure your root location
Locate theweb:locations section and update the root (/) location as follows:
2. Set up a location for uploads
Application containers are read-only by default; WordPress needs a writable location to store uploaded media. To make the location writable, set up a mount. To do so, locate themounts: section that is commented out, and update it as follows:
3. Install dependencies during the build hook
To ensure your Composer dependencies are installed during the build stage, locate thebuild: section (below the hooks: section).Update the
build: section as follows:
You can adjust the composer install command to meet your specific requirements.
4. Launch tasks during the deploy hook
Once the images for our application have been built, there are a few key tasks that must be completed before our newly-built application can receive requests. These tasks include: application can receive requests. Such tasks include:- Flushing the object cache, which might have changed between current production and newly deployed changes
- Running the WordPress database update procedure, in case core is being updated with the newly deployed changes
- Running any due cron jobs
deploy: section (below the build: section). Update the deploy: and post_deploy: sections as follows:
5. Update App container depdencies
Add the wp-cli tool and composer to your application build. Locate thedependencies: section that is commented out,
and update it as follows:
6. Configure your default route
Locate theroutes: section, and beneath it, the "https://{default}/": route. Update the route as follows:
Matching the application name APP_NAME with the upstream definition APP_NAME:http is the most important setting to ensure at this stage.
If these strings aren’t the same, the WordPress deployment will not succeed.
7. Add your crons
Under your application configuration you can now add a cron.8. Update .environment
The CLI generated a .environment file during the Getting started guide. Notice it has already created some environment
variables for you to connect to your database service.
.environment
-
Open the
.environmentfile for editing -
Add the following at the end of the file:
.environment
9. Commit, Push, and Deploy!
You can now commit all the changes made to.upsun/config.yaml and .environment and push to Upsun.
Terminal
9. Routinely run WP Cron (optional)
If your site does not receive enough traffic to ensure WP Cron jobs run in a timely manner, or your site uses caching heavily such that WP Cron isn’t being triggered, you might consider adding a cron job to your project’s configuration to have WP CLI run those scheduled tasks on a routine basis. To do so, locate thecrons: section that is commented out, and update it
as follows:
The above example will trigger the wp-cli every 15th minute to run WP Cron tasks that are due. Feel free to adjust based
on your individual requirements.
When uncommenting, pay attention to the indentation and make sure that the
crons key aligns with other sibling keys (e.g. hooks, dependencies, etc.)