Skip to content
This repository was archived by the owner on Nov 23, 2021. It is now read-only.

Commit 39f45c5

Browse files
committed
Initial commit
0 parents  commit 39f45c5

File tree

41 files changed

+2496
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2496
-0
lines changed

.debops.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DebOps configuration file
2+

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
secret
2+
ansible.cfg

CHANGELOG.md

Whitespace-only changes.

LICENSE

+674
Large diffs are not rendered by default.

README.md

+254
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
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.

inventory/group_vars/all/vars.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# All DebOps defaults are stored here.
2+
# You should overwrite these values in either a group or host vars file.
3+
4+
ntp_timezone: 'Etc/UTC'

inventory/hosts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This is an Ansible inventory file in INI format. You can define a list of
2+
# hosts and groups to be managed by this particular inventory.
3+
4+
# Hosts listed under [all_servers] will have common DebOps plays
5+
# ran against them. It will include services such as iptables, DNS, Postfix,
6+
# sshd configuration and more.
7+
#
8+
# View the list here:
9+
# https://github.com/debops/debops-playbooks/blob/master/playbooks/common.yml
10+
11+
[all_servers]
12+
#<hostname>
13+
14+
[wordpress]
15+
#<hostname>

playbooks/common.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
3+
- name: Common roles for all playbooks
4+
hosts: 'all:!localhost'
5+
sudo: True
6+
7+
roles:
8+
- role: swap

playbooks/wordpress.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
- include: common.yml
4+
5+
- name: Manage WordPress web server
6+
hosts: 'wordpress'
7+
sudo: True
8+
9+
roles:
10+
- { role: wordpress, tags: wordpress }

roles/hhvm/defaults/main.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
3+
# ---- HHVM repository configuration ----
4+
5+
# HHVM keyserver fingerprint
6+
hhvm_keyserver_fingerprint: '0x5a16e7281be7a449'
7+
8+
9+
# ---- HHVM configuration ----
10+
11+
hhvm_pid: '/var/run/hhvm/pid'
12+
13+
# HHVM php.ini settings
14+
hhvm_php_settings:
15+
'log.level': 'Warning'
16+
'log.always_log_unhandled_exceptions': 'true'
17+
'log.runtime_error_reporting_level': '8191'
18+
'mysql.typed_results': 'false'
19+
20+
# HHVM server.ini settings
21+
hhvm_server_settings:
22+
'server.file_socket': '/var/run/hhvm/hhvm.sock'
23+
'server.type': 'fastcgi'
24+
'server.default_document': 'index.php'
25+
'log.use_log_file': 'true'
26+
'log.file': '/var/log/hhvm/error.log'
27+
'header': 'true'
28+
'repo.central.path': 'var/run/hhvm/hhvm.hhbc'
29+
'server.file_socket': ' /var/run/hhvm/hhvm.sock'

roles/hhvm/handlers/main.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
- name: Restart hhvm
4+
service: name=hhvm state=restarted
5+
6+
- name: Reload hhvm
7+
service: name=hhvm state=reloaded

roles/hhvm/meta/main.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
3+
dependencies:
4+
5+
- role: debops.monit
6+
monit_process_list: [ '{{ hhvm_monit_process }}' ]

roles/hhvm/tasks/main.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
3+
# ---- Install and configure HHVM server ----
4+
5+
- name: Add HHVM repository key
6+
apt_key:
7+
url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search={{ hhvm_keyserver_fingerprint }}'
8+
state: 'present'
9+
10+
- name: Add HHVM repository
11+
apt_repository:
12+
repo: 'deb http://dl.hhvm.com/ubuntu {{ ansible_distribution_release }} main'
13+
state: 'present'
14+
update_cache: 'yes'
15+
16+
- name: Install HHVM package
17+
apt:
18+
name: 'hhvm'
19+
force: 'yes'
20+
state: 'latest'
21+
22+
- name: Configure php.ini for HHVM
23+
template:
24+
src: 'etc/hhvm/php.ini.j2'
25+
dest: '/etc/hhvm/php.ini'
26+
owner: 'root'
27+
group: 'root'
28+
mode: '0644'
29+
notify: [ 'Restart hhvm' ]
30+
31+
- name: Configure server.ini for HHVM
32+
template:
33+
src: 'etc/hhvm/server.ini.j2'
34+
dest: '/etc/hhvm/server.ini'
35+
owner: 'root'
36+
group: 'root'
37+
mode: '0644'
38+
notify: [ 'Restart hhvm' ]

0 commit comments

Comments
 (0)