WordPress developers have their own workflows, and they sometimes differ from the usual ones in other CMS or frameworks. However, Bedrock allows you to manage WordPress and related plugins as any other PHP dependency via
composer. It also creates a better project structure that puts WordPress in its own subdirectory. These nice features make Bedrock a great alternative to consider when developing WordPress sites, since you can follow a typical PHP development workflow: Update dependencies locally, commit your
composer.lock, and deploy your application to your testing/staging environment (or to production, eventually).
If you also take advantage of Moss‘s zero-downtime deployments, your WordPress development workflow becomes a breeze. In this article we’ll see how to create and deploy your Bedrock site with Moss. If you don’t have an account yet, sign up at our Free Plan which includes unlimited sites and servers.
Create your Bedrock project
In order to benefit from zero-downtime deployments, you need your WordPress site to be in a git repository. If you have an existing Bedrock project under git source control, you can skip this section and jump onto the next one.
In this example we’re going to create a new Bedrock project called “bedrock” by means of
composer. Once created, let’s init the local git repo, commit our changes, and push them to the corresponding origin. For this post I’ve created a public repo in GitHub called “bedrock”, so my origin is
email@example.com:fjros/bedrock.git (use yours instead).
We already have a minimal Bedrock application under version control. Now it’s time to set up our web and database server before deploying it. You can check the whole process in the following video:
Create the site in Moss
Once you have it, just click New site and fill out the form:
- Select the server.
- Choose WordPress as framework. Don’t check the “Install WordPress” box.
- Select the PHP version you want.
- Create the server user that will run your site.
- Provide the domain name of your site. If you cannot change your DNS records at this moment, you can use the test domain Moss gives you.
- Give your site a name. This name helps you identify your site on that server, even if you change your domain name later on.
- Tell Moss if it must set up HTTPS. In such case, either provide your own certificate or ask Moss to automatically issue and renew free Let’s Encrypt certificates. In case you’re just testing out Moss, you can omit this step and set up the certificate later on – especially if you’re using the test domain suggested by Moss.
- Create a new database connection. For this you must provide the database name, database username, and corresponding password. Moss will create the database, user, and grant the corresponding permissions.
- Check the “Install Postfix” box if you want WordPress to send emails from your server.
webas the root dir.
Finally click Create and Moss will start a background operation to install the required software and perform the related configurations. Once the operation ends, your web and database server’s been configured to host your Bedrock-powered WordPress site. But you haven’t deployed it yet… and that’s what you’ll do in the next steps.
Set your git repo
If you head to the Deployments tab you’ll see the option to add a git repo to the site. In case you haven’t linked your GitLab, GitHub, or Bitbucket account with Moss yet, this is a good time to do it (you can also choose the Custom option if you use a different git provider).
Once you’ve selected the provider, you must choose the user who owns your site’s repo and select the latter from the list that will appear. Tip: If you have many repositories, the search filter will come handy to find the one you want quickly.
Finally, tell Moss the branch or tag it must deploy when you ask for it. Usually this can be
master, but you may adopt the convention you like better (e.g.
While Moss finishes the required configs, let’s set up the deployment process.
Set up your deployments
.env file doesn’t belong to your git repo, since it contains environment-specific content (e.g. development, staging, or production configs) including passwords and secrets. Moss calls these kinds of files (or folders) persistent because they’re shared across deployments. I.e. deploying your website won’t override the
Hence, you must tell Moss that there’s a persistent file called
.env and you must provide it by any other means – since cloning your repo won’t pull that file. The easier way is to edit the file locally and upload it to the proper path on your server using SCP or an SFTP client.
Most of the information you need to fill out the
.env file can be easily obtained from Moss, as shown in the video above. You can generate the remaining secrets from the roots.io site. Here you can see an example of what the file looks like:
E.g. you may upload the file using SCP like this:
Once uploaded, let’s tell Moss the command it must run to build your site during a deployment.
Moss shows you the Deployment Flow it follows during a deployment. You can edit the pre-activation and post-activation scripts it runs. Since you’re setting up a WordPres site using Bedrock, just edit your pre-activation script to run
Add here any other command you may need to build your site, and let’s deploy it at last!
Deploy your WordPress site
You just need to click Deploy. When the corresponding operation is done, you can browse your site and you’ll see the WordPress installator. You may also check the Operation Log to see the details of your deployment.
You may also deploy automatically by pushing your changes to the branch/tag you specified in Moss. In order to enable this feature, head to the Deployment Flow tab and turn on the Push-to-deploy switch.
Additional advantages of using Moss
From now on you can keep coding your application and deploy whenever you need automatically or with a single click. But using Moss hass additional advantages:
- We’ve already seen that all git-based deployments in Moss are zero-downtime. This also means that if a new deployment fails for any reason, your users won’t be impacted because your previous release is being served at every moment.
- You’ll receive a notification via email or Slack when your deployments succeed or fail.
- As you’ve seen in the accompanying video, Moss offers real-time visibility about the operations which are being run on your servers and sites. In addition you can check the log of each operation, what can help you troubleshoot an issue when it comes up.
- You may create the database on a remote server right from Moss, and it automatically opens the firewall so that your application servers may reach the database. Note: Remember to update the
DB_HOSTenv var accordingly in this case.
- Moss performs lots of configurations aimed at improving the security of your servers.
- Only the software that each server actually needs is installed.
- Moss supports teams in all plans (unlimited teammates).
- You may monitor a server and all the sites it hosts for US$5 per month (at most). In this way you can track the resource consumption of your servers, check that your sites are up, or whether they’re reachable via HTTPS, among others. Oh, and you’ll receive an alert if something goes wrong.
- Help Center. Higher plans also include support via chat.
- And more! Moss has lots of features and we keep building more on a regular basis.
In this article we’ve seen how you can follow a typical PHP development flow and easily deploy your WordPress sites without downtime using Bedrock and the Free Plan of Moss. You can use the latter for all your applications and servers, and upgrade to a paid plan only if you need additional integrations, deploy with higher frequency, or reach our support team.