Laravel Forge is a service that handles creating servers on popular cloud hosting providers. I use it to host my WordPress sites with DigitalOcean and to handle auto deployments from a git push.

Installing WordPress on a cloud server you need to plan for failure. Typically there is no guarantee that you will not wake up one morning and find the server just gone. I’ve personally ran into that with AWS in the past and now I always plan for it.

Local Development

I like to do all my testing locally and to handle this I create a wp-config-local.php1 file for all my database settings. This file should be added to .gitignore as you do not want to commit it.

Next modify the wp-config.php file with a simple if/else so it will pull the local file in if it exists.

Also notice the getenv calls which I setup as environmental variables in Forge. This prevents you from committing them and makes your app easy to switch to different servers. It’s not shown in this file but I create environmental variables for all the keys as well.


I’m not a huge fan of plugins. I try to keep the number installed to a bare minimum and only use them if I have a very specific use case.

Since WordPress stores attachment on the disk we need to move those over to s3. I use the following two plugins for this which work together:

This is a good time to review your database backups. Jetpack has VaultPress which is a commercial backup system but others exist. So you should do you research and figure out what suits you best.


Setting up email on a server is never fun. To make it easy I use the wpMandrill plugin which integrates with their mail service. This way if I need to change servers I will not have to setup email again.


Caching isn’t required but if you choose a small server then it will help performance and not overload when you get a spike in traffic. I’m currently using WP Super Cache and have been happy with it.

Wrap up

With these simple plugins and settings your WordPress install will not be dependent on the server for it’s data. You can easily and safely move to different providers or bigger servers without worry.

  1. Hat tip to Pantheon for this setup. 

13 thoughts on “ How to setup WordPress with Forge and DigitalOcean ”

  1. Hi Eric, How well does VaultPress work? I have been using BackWPupt to back my WordPress install to S3. I have yet to have a need to pull a backup back, but it seems like it will happen sometime. I suspect that VaultPress is probably the better of the two options. Is it worth the upgrade? Thanks!


    1. Sorry for the delay in responding. For some reason, I missed your comment. I haven’t used the plugin you are using so I’m not positive on any differences or anything. I’d imagine since VaultPress is official it will always be the safer bet, but I honestly don’t know.


    1. Anthony, Since this post I switched to using an SMTP plugin. I don’t remember running into issues wpMandrill but I also don’t remember why I switched. 🙂

      My recommendation is try one of those if you have issues with it.


  2. Few questions… Forge builds an nginx server, not Apache. WordPress has a whole page dedicated to optimizing your WordPress installation for nginx. I don’t know much about nginx (well, nothing really) and I do realize that the Forge nginx config apparently works out of the box with WordPress, but it is setup differently than how WordPress suggests. I guess I’m wondering if it is better to use the WordPress prescribed nginx config, or keep the default Forge config?

    Also, is WP Super Cache the best choice for caching when using Forge? We aren’t on Apache, so the plugin will use a file-based cache (if I’m not mistaken). Once of the benefits of setting up a server on Forge is that we have memcache installed. Should’t we use a plugin (like W3 Total Cache, or other) that takes advantage of memcache, instead of a slower mechanism like file based caching?

    If I’m not mistaken, when you deploy WordPress via Forge, doesn’t the default deploy script throw an error, because it is setup for Laravel and runs both composer and artisan commands which are not in the WordPress project? Don’t you need to remove those lines from your deploy script?


  3. Hi Mike,

    Thanks for the comments. One of the great things about Forge is you still have complete access to fine tune any of this as you’d like. For example, you could change the nginx config right from the forge UI and then restart the server and be good to go. To answer your first question, yes if WordPress has an official config recommendation then I would use that.

    I’m not certain on WP super cache vs the alternatives. That is the one I went with and so far on a $10 digital ocean box it’s stood up well to being on the front page of HN three different times. Those are my biggest traffic days and it looks like JetPack stats is reporting around 26k views on those. So basically all I’m saying is it held up well under that load and I have no idea how that will compare to the traffic you are expecting.

    Yes, you will need to remove those lines. Basically I have mine set to just do the auto deploy with a git pull and nothing more. I’m also not worried about if that could cause a moment or two of downtime but if you are worried about then I would go with Envoyer which handles symlinking everything and ensuring deployments complete before being swapped over.

    I hope this helps!


    1. Ben,

      I’ve been doing all updates locally first, then committing, and running again on the server. Unfortunately, I’ve not found an ideal workflow for that yet.


  4. HI Eric,

    I am using getenv() in wp-config file and also added environment variables in forge, but when I print $_ENV array it does not have any of the variable which I defined in forge. Also getenv() returns false.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s