Wordpress on fly.io
A starting point for deploying a Wordpress application to fly.io.
Based on wordpress-env.
- Fully dockerized & repeatable.
- Uses SQLite plugin simple database management.
- Runs on locally & on fly.io
- This doesn't cover getting
wp-content/uploads
to persist within a volume, but this can be done using the instructions for thedatabase
volume
Same as wordpress-env
- Create fly.io application:
fly launch
- Fill out
fly launch
questions:
Question | Tip |
---|---|
Choose an app name (leave blank to generate one): | Must be globally unique |
Choose a region for deployment: | Pick the closest region (remember the 3-letter code) |
Would you like to set up a Postgresql database now? | No |
Would you like to set up an Upstash Redis database now? | No |
Create .dockerignore from 1 .gitignore files? | Yes |
Would you like to deploy now? | No (we stil need to set up a volume) |
- Create a volume for the
wp-content/database
directory. This creates a 1gb volume associated with our new app (make sure you replace $REGION_CODE with the 3-letter code from above):
fly volumes create wordpress_database --region $REGION_CODE --size 1
- Replace the
[env]
line infly.toml
with the following lines:
[build.args]
PORT=8080
[mounts]
source="wordpress_database"
destination="/var/www/html/wp-content/database"
[env]
WORDPRESS_CONFIG_EXTRA=""
- Deploy app:
fly deploy
-
Ensure deployment was successful. You can view the deployment progress in your fly.io dashboard > [your new app] > Monitoring
-
SSH into VM and fix volume permission issue.
fly.io
gives theroot
user ownership of the mounted volume, which we must manually fix by running:
fly ssh console
chown -R www-data /var/www/html/wp-content/database
-
Go to the application URL listed in your fly.io dashboard > [your new app] > Overview
-
Follow the Wordpress installation instructions.