|
| 1 | +# DebOps for WordPress |
| 2 | + |
| 3 | +"DebOps for WordPress" is a tool created to give anyone in the WordPress community |
| 4 | +access to a high-performance WordPress server. It's meant to be easy to use and |
| 5 | +require little to no system adminstrator knowledge. |
| 6 | + |
| 7 | +It takes care of everything for you. It's not just installing WordPress. It also takes |
| 8 | +care of all the server configuration. It'll handle the setup of: |
| 9 | + |
| 10 | + * Automatic updates |
| 11 | + * MySQL backups |
| 12 | + * Fail2ban |
| 13 | + * Firewall |
| 14 | + * And a lot more |
| 15 | + |
| 16 | +On top of all that, you'll also have a working WordPress installation using: |
| 17 | + |
| 18 | +* Nginx |
| 19 | +* MariaDB |
| 20 | +* HHVM |
| 21 | +* PHP-FPM (automatic fallback) |
| 22 | +* Redis |
| 23 | +* WP-CLI |
| 24 | +* Varnish (optimized for WordPress) |
| 25 | + |
| 26 | +All that you need to do is type in two command lines. |
| 27 | + |
| 28 | +## Requirements |
| 29 | + |
| 30 | +### Your server |
| 31 | + |
| 32 | +You'll need an Ubuntu server (14.04 LTS version is prefered) that you can connect to |
| 33 | +using an SSH key. To configure a server with SSH, please refer to the server creation guide |
| 34 | +for your cloud hosting provider. |
| 35 | + |
| 36 | +If there isn't one, please refer to your hosting provider's guide for configuring SSH. You |
| 37 | +may also create an issue to create a guide for that specific hosting provider. |
| 38 | + |
| 39 | +### Your computer |
| 40 | + |
| 41 | +In order to use "DebOps for WordPress", you'll need to install Ansible and [DebOps](http://debops.org) |
| 42 | +on your computer. You can only install these on MacOS X or Linux. |
| 43 | + |
| 44 | +#### Install pip |
| 45 | + |
| 46 | +The easiest way to install Ansible and DebOps is with [pip](https://pip.pypa.io). If it isn't already |
| 47 | +installed, you can install it using one of the following command lines. |
| 48 | + |
| 49 | +On MacOS X: |
| 50 | + |
| 51 | +```bash |
| 52 | +sudo easy_install pip |
| 53 | +``` |
| 54 | + |
| 55 | +On Debian and Ubuntu: |
| 56 | + |
| 57 | +```bash |
| 58 | +sudo apt-get install python-pip |
| 59 | +``` |
| 60 | + |
| 61 | +On Fedora: |
| 62 | + |
| 63 | +```bash |
| 64 | +sudo yum install python-pip |
| 65 | +``` |
| 66 | + |
| 67 | +#### Install Ansible |
| 68 | + |
| 69 | +Due to an [Ansible bug](https://github.com/ansible/ansible/issues/10675), you will need to install a |
| 70 | +specific version of Ansible. |
| 71 | + |
| 72 | +```bash |
| 73 | +pip uninstall ansible |
| 74 | +pip install -Iv https://pypi.python.org/packages/source/a/ansible/ansible-1.9.0.1.tar.gz |
| 75 | +``` |
| 76 | + |
| 77 | +#### Install DebOps |
| 78 | + |
| 79 | +Installing DebOps is done through pip as well. |
| 80 | + |
| 81 | +```bash |
| 82 | +pip install debops |
| 83 | +``` |
| 84 | + |
| 85 | +For MacOS X users, you'll need to do another step due to another [Ansible bug](https://github.com/ansible/ansible/issues/8555). |
| 86 | +Replace `{username}` with your own username. |
| 87 | + |
| 88 | +```bash |
| 89 | +ln -s /Users/{username}/Library/Application\ Support/debops /usr/local/share/debops |
| 90 | +``` |
| 91 | + |
| 92 | +You'll also need to set `/usr/local/share/debops` in your `.debops.cfg` as such: |
| 93 | + |
| 94 | +```ini |
| 95 | +data-home: /usr/local/share/debops |
| 96 | +``` |
| 97 | + |
| 98 | +## Installation |
| 99 | + |
| 100 | +To create a "DebOps for WordPress" project, you just need to: |
| 101 | + |
| 102 | + 1. Get a copy of this repo to your computer. |
| 103 | + 2. Make sure that DebOps is up to date by running `debops-update`. |
| 104 | + |
| 105 | +## Configure your first server |
| 106 | + |
| 107 | +Before you can begin configuring your server, you need to create a server for DebOps to configure. |
| 108 | + |
| 109 | +### SSH Key required |
| 110 | + |
| 111 | +DebOps requires that you add an SSH key to connect to your server. It replaces the need for a password |
| 112 | +and encrypts all communication with your server. |
| 113 | + |
| 114 | +You can see the [GitHub documentation](https://help.github.com/articles/generating-ssh-keys/) to create |
| 115 | +your own. Most provider instructions will also show you how to create and add your SSH key to your server. |
| 116 | + |
| 117 | +### Cloud hosting provider instructions |
| 118 | + |
| 119 | +Here are some detailed instructions to setup your server with specific cloud hosting providers. |
| 120 | + |
| 121 | +#### Digital Ocean |
| 122 | + |
| 123 | +Before you begin, you have to make sure that you've created an [SSH key in Digital Ocean](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets). You only need to do this once. |
| 124 | + |
| 125 | +You want to click on `Create droplet` in the Digital Ocean control panel |
| 126 | + |
| 127 | +[picture top of page] |
| 128 | + |
| 129 | +Replace `debops-wordpress` with the name that you want for your server. DebOps will use that name to |
| 130 | +store all server specific passwords in the `secret` directory. |
| 131 | + |
| 132 | +[picture middle of the page] |
| 133 | + |
| 134 | +Select a region that fits best for you. You don't need to select anything under `Available Settings`. |
| 135 | + |
| 136 | +[picture bottom of the page] |
| 137 | + |
| 138 | +The last step is to select your Linux. The default Ubuntu version (14.04 x64) is the best option here. Make |
| 139 | +sure to also select an SSH key for the server. |
| 140 | + |
| 141 | +Press `Create Droplet` and wait for your server to come online. |
| 142 | + |
| 143 | +### DNS record |
| 144 | + |
| 145 | +Once your server is created, you'll want to create a DNS record for your server. This isn't |
| 146 | +necessary, but the default settings will work better with an address. |
| 147 | + |
| 148 | +### DebOps playbooks |
| 149 | + |
| 150 | +Now that you have your server, it's time to install everything using DebOps. This is only two |
| 151 | +command lines, but each of them takes between 5 and 10 minutes. |
| 152 | + |
| 153 | +### Add your server to the host file |
| 154 | + |
| 155 | +First, you'll need to add the address of your new server to the `host` file found in `{project_root}/inventory`. |
| 156 | +The server name needs to be added under both the `[all_server]` and `[wordpress]` as such: |
| 157 | + |
| 158 | +```ini |
| 159 | +[all_servers] |
| 160 | +wordpress.example.com |
| 161 | + |
| 162 | +[wordpress] |
| 163 | +wordpress.example.com |
| 164 | +``` |
| 165 | + |
| 166 | +#### Run the common DebOps playbook |
| 167 | + |
| 168 | +Your first step is to install and configure all essential services. These include iptables, DNS, Postfix, |
| 169 | +sshd configuration and much more. You just need to type in this command to get started: |
| 170 | + |
| 171 | +```bash |
| 172 | +debops -u root |
| 173 | +``` |
| 174 | + |
| 175 | +You'll get the following warning almost right away. |
| 176 | + |
| 177 | +```bash |
| 178 | +PLAY [Gather default and custom facts] **************************************** |
| 179 | + |
| 180 | +GATHERING FACTS *************************************************************** |
| 181 | +The authenticity of host '123.456.78.90 (123.456.78.90)' can't be established. |
| 182 | +RSA key fingerprint is 11:eb:57:f3:a5:c3:e0:77:47:c4:15:3a:3c:df:6c:d2. |
| 183 | +Are you sure you want to continue connecting (yes/no)? |
| 184 | +``` |
| 185 | +
|
| 186 | +Type `yes` and Enter to continue. This step can take 5-10 minutes. So go grab a coffee or take stretch |
| 187 | +while the magic happen. |
| 188 | +
|
| 189 | +#### Run the WordPress DebOps playbook |
| 190 | +
|
| 191 | +Now, you still don't have a configured WordPres site. You still need to install and configure all |
| 192 | +WordPress related services. This is done using this command: |
| 193 | + |
| 194 | +```bash |
| 195 | +debops wordpress -u root |
| 196 | +``` |
| 197 | +You don't need to wait for a prompt this time. You can just sit and relax. This step can take 5-10 minutes as well. |
| 198 | +
|
| 199 | +### Your server |
| 200 | +
|
| 201 | +Once the second script is done, your server will be configured and functional. You can visit your site at |
| 202 | +`wordpress.example.com` (replace this with the address you used). |
| 203 | +
|
| 204 | +You can SSH to it using the root account: |
| 205 | +
|
| 206 | +```bash |
| 207 | +ssh wordpress.example.com - l root |
| 208 | +``` |
| 209 | +
|
| 210 | +## Performance tuning |
| 211 | +
|
| 212 | +Here are some extra steps you can take to improve the performance and behaviour of your server. |
| 213 | +
|
| 214 | +### Recommended plugins |
| 215 | +
|
| 216 | +Here are some recommended plugins that you can add to your WordPress installation to improve its |
| 217 | +performance further. |
| 218 | +
|
| 219 | +#### Varnish Purge Plugin |
| 220 | +
|
| 221 | +While Varnish has a solid WordPress configuration, it can't detect when you're making changes to posts. |
| 222 | +[This plugin](https://wordpress.org/plugins/varnish-http-purge/) notifies Varnish when you make changes |
| 223 | +to existing posts. It'll tell it to purge the relevant pages from the cache. This ensures that visitors |
| 224 | +always see the up-to-date post content. |
| 225 | + |
| 226 | +#### Redis Object Cache |
| 227 | + |
| 228 | +Your server comes preconfigured with Redis, but the object cache isn't installed by default. To use the |
| 229 | +object cache, you'll need to install [this plugin](https://wordpress.org/plugins/redis-cache/). |
| 230 | + |
| 231 | +#### TinyPNG |
| 232 | + |
| 233 | +Your site might still feel slow even with the best configuration possible. That's because your visitors |
| 234 | +still need to download images on your page. If they aren't compressed, this can be an issue that affects |
| 235 | +performance. [This plugin](https://wordpress.org/plugins/tiny-compress-images/) takes care of that. It's |
| 236 | +[been found](https://www.mattcromwell.com/battle-of-the-image-compression-wordpress-plugins/) to give the |
| 237 | +best result in terms of compression. |
| 238 | +
|
| 239 | +#### RICG |
| 240 | +
|
| 241 | +Even with proper compression, your site might still feel slow on mobile devices. You want to make sure that |
| 242 | +you use the right image for the right devices. [This plugin](https://wordpress.org/plugins/ricg-responsive-images/) |
| 243 | +will take care of all of that for you. |
| 244 | +
|
| 245 | +## Acknowledgements |
| 246 | +
|
| 247 | +DebOps is the real cornerstone of this project. This project wouldn't exists without the amazing work done |
| 248 | +by [Maciej Delmanowski](https://github.com/drybjed). |
| 249 | + |
| 250 | +A lot of the initial inspiration for the roles came from WPEngine's [Mecury project](https://github.com/wpengine/hgv) |
| 251 | +and [the port](https://github.com/zach-adams/hgv-deploy-full) done by [Zach Adams](http://zach-adams.com/). |
| 252 | +
|
| 253 | +The [default Varnish configuration](https://github.com/mattiasgeniar/varnish-4.0-configuration-templates) work by |
| 254 | +[Mattias Geniar](http://ma.ttias.be/) was critical to get a solid foundation for Varnish in WordPress. |
0 commit comments