Skip to main content
Setting up a WordPress application on Fly.io is quite simple. In this guide, we’ll learn just how simple it is! There’s one thing you need before setting up a WordPress application: a MySQL database. You can find out how to get one set up on Fly.io in this handy guide. Make sure you remember the hostname (this will be <your-mysql-app-name>.internal), the database name and the database credentials. Ready? Let’s get started!

Launch a new WordPress application

To launch a new WordPress application, we can use the official WordPress docker image. To do so, run the following command:
Type n if you’re happy with the defaults listed, otherwise type y to open the Fly Launch web page and edit your settings, including:
  • Name: Keep the default app name or enter your own. This name will be part of the URL for your app, unless you use a custom domain.
  • Region: Keep the fastest region (the value of primary_region in the fly.toml file) as chosen by Fly Launch, or select a different region to deploy to.
After you click Confirm Settings, Fly Launch creates your App and generates a fly.toml file for your project with the settings. The reason we added the --no-deploy flag is so that the App doesn’t get deployed right away. This way, we can set up things like secrets and environment variables before the first deployment.

Configure & deploy the WordPress application

Before deploying, we’ll need to configure a couple of things. In your newly created fly.toml file, change the internal_port under [http_service] from 8080 to 80. This setting lets Fly know on what port your App will respond, which is 80 in our case. After that, set up these environment variables by adding this to the end of your fly.toml:
The WORDPRESS_DB_NAME and WORDPRESS_DB_HOST are needed for the WordPress application to connect to the database. The WORDPRESS_CONFIG_EXTRA makes sure that the application serves everything from the https://... address. Here’s how the total fly.toml should look now:
Next, we need to set up the WORDPRESS_DB_USER and WORDPRESS_DB_PASSWORD variables. Since these are sensitive, let’s use the fly secrets command:
You can list the secrets you’ve already set using fly secrets list. For example:
The values aren’t displayed, since they’re secret!

Deploy your app

The last step is to deploy the App with the deploy command:

Set up a custom domain

You probably want to set up a custom domain for your WordPress application. You can find all you need to know (and more!) in this handy guide.

Open your app

Run fly apps open, or just go to the URL specified in the output of the deploy command, to open your deployed App in a browser. If you have any questions, need help, or want to talk about what you’re building, visit our community forum.