Merge lp:~jose/charms/precise/wordpress/fix-1309980 into lp:charms/wordpress
- Precise Pangolin (12.04)
- fix-1309980
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 76 | ||||||||
Proposed branch: | lp:~jose/charms/precise/wordpress/fix-1309980 | ||||||||
Merge into: | lp:charms/wordpress | ||||||||
Diff against target: |
343 lines (+133/-63) 4 files modified
README.md (+124/-60) hooks/cache-relation-changed (+5/-0) hooks/install (+2/-2) inc/common (+2/-1) |
||||||||
To merge this branch: | bzr merge lp:~jose/charms/precise/wordpress/fix-1309980 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Ceppi (community) | Approve | ||
Matt Bruzek (community) | Needs Fixing | ||
Review via email: mp+216568@code.launchpad.net |
Commit message
Description of the change
Fixed bug #1309980, which throws an error when WP-FFPC is installed due to a relation with memcached. I added a note to the README file as error #1 displayed on the bug (files not being saved) needs to be fixed manually by clicking 'Save Changes' on the WP-FFPC Settings page, as I couldn't find a way to save changes from the CLI.
Also, fixed 80-line wrapping on the README.md file.
Marco Ceppi (marcoceppi) wrote : | # |
José Antonio Rey (jose) wrote : | # |
It's doubled if you check correctly.
Matt Bruzek (mbruzek) wrote : | # |
José
Thanks for your submission on the wordpress charm! Taking the initiative to fix this bug is awesome and I really appreciate it!
I ran the following steps to get this bug with the current wordpress charm (before I downloaded the code).
juju deploy --repository . local:precise/
juju deploy mysql
juju deploy haproxy
juju deploy memcached
juju add-relation mysql wordpress
juju add-relation haproxy wordpress
juju expose haproxy
(wait for the environment to deploy)
juju add-relation memcached wordpress
The wordpress hook ends up with an error:
wordpress/0:
The log indicates:
sed: can't read /var/www/
When I merge the changes from this MP and deploy with the same steps I see this same error!
2014-05-20 21:57:48 INFO cache-relation-
2014-05-20 21:57:48 ERROR juju.worker.uniter uniter.go:490 hook failed: exit status 2
- - - - -
José and I had a chat about this on IRC and he was not able to see the same error. The only differences that we noticed was the version of juju and the environments. José is running 1.18.1-trusty-amd, and I am running 1.19.2-trusty-amd and he is using Amazon, and I was using local LXC. Other than that we had the same bzr revision and deployed in an almost identical way.
This still looks like a problem so I am going to move this to “incomplete” until we can find the root cause. Please move this back to “needs review” when you have fixed the problem.
Thank you for your continued work on this and working with me on IRC!
Matt Bruzek (mbruzek) wrote : | # |
Thanks again for the submission. I'm going to change status of this MP to "needs fixing" and when you are ready for another review please click the "Request another review" button in the upper right hand corner of the commit message.
Preview Diff
1 | === modified file 'README.md' |
2 | --- README.md 2013-12-12 18:42:27 +0000 |
3 | +++ README.md 2014-06-30 21:18:30 +0000 |
4 | @@ -1,12 +1,16 @@ |
5 | # Overview |
6 | |
7 | -WordPress is a powerful blogging platform written in PHP. This charm aims to deploy WordPress in a fashion that will allow anyone to scale and grow out |
8 | -a single installation. |
9 | +WordPress is a powerful blogging platform written in PHP. This charm aims to |
10 | +deploy WordPress in a fashion that will allow anyone to scale and grow out a |
11 | +single installation. |
12 | |
13 | # Usage |
14 | |
15 | -This charm is available in the Juju Charm Store, to deploy you'll need at a minimum: a cloud environment, a working Juju installation, |
16 | -and a successful bootstrap. Please refer to the [Juju Getting Started](https://juju.ubuntu.com/docs/getting-started.html) documentation before continuing. |
17 | +This charm is available in the Juju Charm Store, to deploy you'll need at a |
18 | +minimum: a cloud environment, a working Juju installation, and a successful |
19 | +bootstrap. Please refer to the |
20 | +[Juju Getting Started](https://juju.ubuntu.com/docs/getting-started.html) |
21 | +documentation before continuing. |
22 | |
23 | Once bootstrapped, deploy the MySQL charm then this WordPress charm: |
24 | |
25 | @@ -23,7 +27,9 @@ |
26 | |
27 | ## Scaled Down Usage for Personal Use |
28 | |
29 | -If you're just looking to run a personal blog and want to save money you can run all of this on a single node, here's an entire single node installation from scratch: |
30 | +If you're just looking to run a personal blog and want to save money you can run |
31 | +all of this on a single node, here's an entire single node installation from |
32 | +scratch: |
33 | |
34 | juju bootstrap |
35 | juju deploy --to 0 wordpress |
36 | @@ -31,40 +37,59 @@ |
37 | juju add-relation wordpress mysql |
38 | juju expose wordpress |
39 | |
40 | -This will run everything on one node, however we still have the flexibility to grow horizontally. If your blog gets more traffic and you need to scale: |
41 | +This will run everything on one node, however we still have the flexibility to |
42 | +grow horizontally. If your blog gets more traffic and you need to scale: |
43 | |
44 | juju add-unit wordpress |
45 | |
46 | -Since we're omitting the `--to` command Juju will fire up a new dedicated machine for Wordpress and relate it. You can also `remove-unit` when the surge is over and go back to a cheaper one node set up. |
47 | +Since we're omitting the `--to` command Juju will fire up a new dedicated |
48 | +machine for Wordpress and relate it. You can also `remove-unit` when the surge |
49 | +is over and go back to a cheaper one node set up. |
50 | |
51 | # Scale Out Usage |
52 | |
53 | -You can deploy a memcached server and relate it to your WordPress service to add memcache caching. This will |
54 | -automagically install [WP-FFPC](http://wordpress.org/extend/plugins/wp-ffpc/) (regardless of your tuning settings) and configure it to cache |
55 | -rendered pages to the memcache server. In addition to this layer of caching, Nginx will pull directly from memcached bypassing PHP altogether. |
56 | -You could theoretically then turn off php5-fpm on all of your servers and just have Nginx serve static content via memcached (though, you |
57 | -wouldn't be able to access the admin panel or any uncached pages - it's just a potential scenario). |
58 | +You can deploy a memcached server and relate it to your WordPress service to add |
59 | +memcache caching. This will automagically install |
60 | +[WP-FFPC](http://wordpress.org/extend/plugins/wp-ffpc/) (regardless of your |
61 | +tuning settings) and configure it to cache rendered pages to the memcache |
62 | +server. In addition to this layer of caching, Nginx will pull directly from |
63 | +memcached bypassing PHP altogether. You could theoretically then turn off |
64 | +php5-fpm on all of your servers and just have Nginx serve static content via |
65 | +memcached (though, you wouldn't be able to access the admin panel or any |
66 | +uncached pages - it's just a potential scenario). |
67 | |
68 | juju deploy memcached |
69 | juju add-relation memcached wordpress |
70 | |
71 | -This setup will also synchronize the flushing of cache across all WordPress nodes, making it ideal to avoid stale caches. |
72 | - |
73 | -A small note, when using the Apache2 engine and memcache, all request will still be sent to WordPress via Apache where typical caching |
74 | -procedures will take place and wp-ffpc will render the memcached page. |
75 | +This setup will also synchronize the flushing of cache across all WordPress |
76 | +nodes, making it ideal to avoid stale caches. |
77 | + |
78 | +Once the relation is set and the hooks have ran accordingly, you will need to |
79 | +manually save the settings for WP-FFPC. Everything will be configured, though. |
80 | +Just log in to the administrator Dashboard, and then click the link to the |
81 | +WP-FFPC Settings page displayed on the error at the top of the page. Finally, |
82 | +scroll down and click on the blue button which says Save Changes. |
83 | + |
84 | +A small note, when using the Apache2 engine and memcache, all request will |
85 | +still be sent to WordPress via Apache where typical caching procedures will take |
86 | +place and wp-ffpc will render the memcached page. |
87 | |
88 | # Configuration |
89 | |
90 | -This WordPress charm comes with several tuning levels designed to encompass the different styles in which this charm will be used. |
91 | +This WordPress charm comes with several tuning levels designed to encompass the |
92 | +different styles in which this charm will be used. |
93 | |
94 | A use case for each tuning style is outlined below: |
95 | |
96 | ## Bare |
97 | |
98 | -The Bare configuration option is meant for those who wish to run the stock WordPress setup with no caching, no manipulation of data, |
99 | -and no additional scale out features enabled. This is ideal if you intend to install additional plugins to deal with coordinating |
100 | -WordPress units or simply wish to test drive WordPress as it is out of the box. This will still create a load-balancer when an additional |
101 | -unit is created, though everything else will be turned off (WordPress caching, APC OpCode caching, and NFS file sharing). |
102 | +The Bare configuration option is meant for those who wish to run the stock |
103 | +WordPress setup with no caching, no manipulation of data, and no additional |
104 | +scale out features enabled. This is ideal if you intend to install additional |
105 | +plugins to deal with coordinating WordPress units or simply wish to test drive |
106 | +WordPress as it is out of the box. This will still create a load-balancer when |
107 | +an additional unit is created, though everything else will be turned off |
108 | +(WordPress caching, APC OpCode caching, and NFS file sharing). |
109 | |
110 | To run this WordPress charm under a bare tuning level execute the following: |
111 | |
112 | @@ -72,11 +97,14 @@ |
113 | |
114 | ## Single |
115 | |
116 | -When running in Single mode, this charm will make every attempt to provide a solid base for your WordPress install. By running in single |
117 | -the following will be enabled: Nginx microcache, APC OpCode caching, WordPress caching module, and the ability to sync files via NFS. |
118 | -While Single mode is designed to allow for scaling out, it's meant to only scale out for temporary relief; say in the event of a large |
119 | -traffic in-flux. It's recommended for long running scaled out versions that optimized is used. The removal of the file share speeds up |
120 | -the site and servers ensuring that the most efficient set up is provided. |
121 | +When running in Single mode, this charm will make every attempt to provide a |
122 | +solid base for your WordPress install. By running in single the following will |
123 | +be enabled: Nginx microcache, APC OpCode caching, WordPress caching module, |
124 | +and the ability to sync files via NFS. While Single mode is designed to allow |
125 | +for scaling out, it's meant to only scale out for temporary relief; say in the |
126 | +event of a large traffic in-flux. It's recommended for long running scaled out |
127 | +versions that optimized is used. The removal of the file share speeds up the |
128 | +site and servers ensuring that the most efficient set up is provided. |
129 | |
130 | To run this WordPress charm under a single tuning level execute the following: |
131 | |
132 | @@ -84,21 +112,29 @@ |
133 | |
134 | ## Optimized |
135 | |
136 | -If you need to run WordPress on more than one instance constantly, or require scaling out and in on a regular basis, then Optimized is the |
137 | -recommended configuration. When you run WordPress under an Optimized tuning level, the ability to install, edit, and upgrade themes and plugins |
138 | -is disabled. By doing this the charm can drop the need for an NFS mount which is inefficient and serve everything from it's local disk. |
139 | -Everything else provided in Single level is available. In order to install or modify plugins with this setup you'll need to edit and commit |
140 | -them to a forked version of the charm in the files/wordpress/ directory. |
141 | +If you need to run WordPress on more than one instance constantly, or require |
142 | +scaling out and in on a regular basis, then Optimized is the recommended |
143 | +configuration. When you run WordPress under an Optimized tuning level, the |
144 | +ability to install, edit, and upgrade themes and plugins is disabled. By doing |
145 | +this the charm can drop the need for an NFS mount which is inefficient and serve |
146 | +everything from it's local disk. Everything else provided in Single level is |
147 | +available. In order to install or modify plugins with this setup you'll need to |
148 | +edit and commit them to a forked version of the charm in the files/wordpress/ |
149 | +directory. |
150 | |
151 | -To run this WordPress charm under an optimized tuning level execute the following: |
152 | +To run this WordPress charm under an optimized tuning level execute the |
153 | +following: |
154 | |
155 | juju set wordpress tuning=optimized |
156 | |
157 | ### Handling wp-content |
158 | |
159 | -In order to allow for custom WordPress content within the Juju charm a separate configuration option exists for pointing to any Git or Bzr |
160 | -repository. An example of a valid formed wp-content repository can be found on the [Juju Tools Github page](https://github.com/jujutools/wordpress-site). |
161 | -To set the wp-content directive to a git repository, use one of the following formats making sure to replace items like `host`, `path`, and `repo` with their |
162 | +In order to allow for custom WordPress content within the Juju charm a separate |
163 | +configuration option exists for pointing to any Git or Bzr repository. An |
164 | +example of a valid formed wp-content repository can be found on the |
165 | +[Juju Tools Github page](https://github.com/jujutools/wordpress-site). To set |
166 | +the wp-content directive to a git repository, use one of the following formats |
167 | +making sure to replace items like `host`, `path`, and `repo` with their |
168 | respective names: |
169 | |
170 | juju set wordpress wp-content=git@host:path/repo.git |
171 | @@ -111,7 +147,9 @@ |
172 | |
173 | juju set wordpress wp-content=git://host/path/repo.git |
174 | |
175 | -If you wish to use a bzr repository, then apply one of the following schemes replacing items like `host`, `username`, `path`, and `repo` with their respective values: |
176 | +If you wish to use a bzr repository, then apply one of the following schemes |
177 | +replacing items like `host`, `username`, `path`, and `repo` with their |
178 | +respective values: |
179 | |
180 | For LaunchPad hosted repostiories: |
181 | |
182 | @@ -125,15 +163,20 @@ |
183 | |
184 | juju set wordpress wp-content=bzr+ssh://host/path/repo |
185 | |
186 | -Setting the wp-content option to an empty string ("") will result in no further updates being pulled from that repository; however, the last pull will remain |
187 | -on the system and will not be removed. |
188 | +Setting the wp-content option to an empty string ("") will result in no further |
189 | +updates being pulled from that repository; however, the last pull will remain on |
190 | +the system and will not be removed. |
191 | |
192 | ## debug |
193 | |
194 | -This option will create a directory `_debug` at the root of each unit (`http://unit-address/_debug`). In this directory are two scripts: info.php (`/_debug/info.php`) |
195 | -and apc.php (`/_debug/apc.php`). info.php is a simple phpinfo script that will outline exactly how the environment is configured. apc.php is the APC admin portal which |
196 | -provides APC caching details in addition to several administrative functions like clearing the APC cache. This should never be set to "yes" in production as it exposes |
197 | -detailed information about the environments and may provide a way for an intruder to DDoS the machine. |
198 | +This option will create a directory `_debug` at the root of each unit |
199 | +(`http://unit-address/_debug`). In this directory are two scripts: info.php |
200 | +(`/_debug/info.php`) and apc.php (`/_debug/apc.php`). info.php is a simple |
201 | +phpinfo script that will outline exactly how the environment is configured. |
202 | +apc.php is the APC admin portal which provides APC caching details in addition |
203 | +to several administrative functions like clearing the APC cache. This should |
204 | +never be set to "yes" in production as it exposes detailed information about the |
205 | +environments and may provide a way for an intruder to DDoS the machine. |
206 | |
207 | juju set wordpress debug=yes |
208 | |
209 | @@ -145,10 +188,15 @@ |
210 | |
211 | ## Engine |
212 | |
213 | -By default the WordPress charm will install nginx and php5-fpm to serve pages. In the event you do not wish to use nginx - for whatever reason - you can switch to Apache2. |
214 | -This will provide a near identical workflow as if you were using nginx with one key difference: memcached. In nginx, the cached pages are served from memcached prior to |
215 | -hitting the php contents, this isn't possible with apache2. As such memcached support still works, since it falls back to the WordPress caching engine, but it's not as robust. |
216 | -Otherwise, Apache2 will still perform balancing and everything else mentioned above. You can switch between engines at will with the following: |
217 | +By default the WordPress charm will install nginx and php5-fpm to serve pages. |
218 | +In the event you do not wish to use nginx - for whatever reason - you can switch |
219 | +to Apache2. This will provide a near identical workflow as if you were using |
220 | +nginx with one key difference: memcached. In nginx, the cached pages are served |
221 | +from memcached prior to hitting the php contents, this isn't possible with |
222 | +apache2. As such memcached support still works, since it falls back to the |
223 | +WordPress caching engine, but it's not as robust. Otherwise, Apache2 will still |
224 | +perform balancing and everything else mentioned above. You can switch between |
225 | +engines at will with the following: |
226 | |
227 | juju set wordpress engine=apache2 |
228 | |
229 | @@ -162,38 +210,54 @@ |
230 | |
231 | ## HP Cloud |
232 | |
233 | -At this time WordPress + Memcached don't work on HP Cloud's standard.xsmall. To get around this deploy the WordPress charm with the |
234 | -charm to at least a `standard.small`, to do this: |
235 | +At this time WordPress + Memcached don't work on HP Cloud's standard.xsmall. To |
236 | +get around this deploy the WordPress charm with the charm to at least a |
237 | +`standard.small`, to do this: |
238 | |
239 | juju deploy --constraints "instance-type=standard.small" wordpress |
240 | |
241 | -This only is a problem when attempting to relate memcached to WordPress, otherwise an xsmall is _okay_ though it's really not the best |
242 | -sized platform for running a stable WordPress install. |
243 | +This only is a problem when attempting to relate memcached to WordPress, |
244 | +otherwise an xsmall is _okay_ though it's really not the best sized platform for |
245 | +running a stable WordPress install. |
246 | |
247 | ## Single mode and the scale-out |
248 | |
249 | -If you're in Single mode and you want to/need to scale out, but you've been upgrading, modifying, and installing plugins + themes like |
250 | -a normal WordPress user on a normal install; you can still scale out but you'll need to deploy a shared-fs charm first. At the time of |
251 | -this writing only the NFS charm will work, but as more shared-fs charms come out (gluster, ceph, etc) that provide a shared-fs/mount |
252 | -interface those should all work as well. In this example we'll use NFS: |
253 | +If you're in Single mode and you want to/need to scale out, but you've been |
254 | +upgrading, modifying, and installing plugins + themes like a normal WordPress |
255 | +user on a normal install; you can still scale out but you'll need to deploy a |
256 | +shared-fs charm first. At the time of this writing only the NFS charm will work, |
257 | +but as more shared-fs charms come out (gluster, ceph, etc) that provide a |
258 | +shared-fs/mount interface those should all work as well. In this example we'll |
259 | +use NFS: |
260 | |
261 | juju deploy nfs |
262 | juju add-relation nfs wordpress:nfs |
263 | |
264 | -By doing so, everything in the wp-contents directory is moved to this NFS mount and then shared to all future WordPress units. It's strongly |
265 | -recommended that you first deploy the nfs mount, _then_ scale WordPress out. Failure to do so may result in data loss. Once nfs is deployed, |
266 | -running, and related you can scale out the WordPress unit using the following command: |
267 | +By doing so, everything in the wp-contents directory is moved to this NFS mount |
268 | +and then shared to all future WordPress units. It's strongly recommended that |
269 | +you first deploy the nfs mount, _then_ scale WordPress out. Failure to do so may |
270 | +result in data loss. Once nfs is deployed, running, and related you can scale |
271 | +out the WordPress unit using the following command: |
272 | |
273 | juju add-unit wordpress |
274 | |
275 | -In the event you want more than one unit at a time (and do not wish to run the add-unit command multiple times) you can supply a `-n` number |
276 | -of units to add, so to add three more units: |
277 | +In the event you want more than one unit at a time (and do not wish to run the |
278 | +add-unit command multiple times) you can supply a `-n` number of units to add, |
279 | +so to add three more units: |
280 | |
281 | juju add-unit -n3 wordpress |
282 | |
283 | +## Memcached Issues |
284 | + |
285 | +In order to have a working relation with memcached, you need to first set up |
286 | +your Wordpress blog, by creating your first user. If you try to relate |
287 | +memcached before, you will get a `cache-relation-changed` error on your |
288 | +instance. |
289 | + |
290 | # Contact Information |
291 | |
292 | ## WordPress Contact Information |
293 | |
294 | - [WordPress Homepage](http://www.wordpress.org) |
295 | -- [Reporting bugs](http://codex.wordpress.org/Reporting_Bugs) on WordPress itself |
296 | \ No newline at end of file |
297 | +- [Reporting bugs](http://codex.wordpress.org/Reporting_Bugs) on WordPress |
298 | +itself |
299 | |
300 | === modified file 'hooks/cache-relation-changed' |
301 | --- hooks/cache-relation-changed 2012-08-24 20:59:04 +0000 |
302 | +++ hooks/cache-relation-changed 2014-06-30 21:18:30 +0000 |
303 | @@ -6,6 +6,11 @@ |
304 | |
305 | rm -f .memcache |
306 | |
307 | +if [ -z $memcache_port ]; then |
308 | + juju-log "Info hasn't been received from the instance yet, exiting silently" |
309 | + exit 0 |
310 | +fi |
311 | + |
312 | cat > .memcache <<EOF |
313 | #!/bin/bash |
314 | CACHE_HOST=$memcache_host |
315 | |
316 | === modified file 'hooks/install' |
317 | --- hooks/install 2013-09-27 18:31:24 +0000 |
318 | +++ hooks/install 2014-06-30 21:18:30 +0000 |
319 | @@ -6,8 +6,8 @@ |
320 | apt-get update && apt-get -y upgrade |
321 | |
322 | apt-get -y install php5-memcache mysql-client pwgen php5 php5-fpm \ |
323 | - php-apc mailutils php-mail sysstat php5-mysql php5-mcrypt php5-memcache \ |
324 | - charm-helper-sh php5-curl rsync nfs-common git-core mktemp |
325 | + php-apc mailutils php-mail sysstat php5-mysql php5-mcrypt charm-helper-sh \ |
326 | + php5-curl rsync nfs-common git-core mktemp |
327 | |
328 | modprobe nfs || true |
329 | |
330 | |
331 | === modified file 'inc/common' |
332 | --- inc/common 2013-09-19 12:18:50 +0000 |
333 | +++ inc/common 2014-06-30 21:18:30 +0000 |
334 | @@ -200,7 +200,8 @@ |
335 | source .memcache |
336 | |
337 | wp plugin install --path=$wp_install_path wp-ffpc |
338 | - sed -i -e "s/'host'=>.*/'host'=>'$CACHE_HOST',/" $wp_install_path/wp-content/plugins/wp-ffpc/wp-ffpc.php |
339 | + sed -i -e "s/'hosts'=>.*/'hosts'=>'$CACHE_HOST:$CACHE_PORT',/" $wp_install_path/wp-content/plugins/wp-ffpc/wp-ffpc.php |
340 | + sed -i "s/memcached/memcache/g" $wp_install_path/wp-content/plugins/wp-ffpc/wp-ffpc.php |
341 | wp plugin activate --path=$wp_install_path wp-ffpc |
342 | |
343 | install -o www-data -g www-data -m 0644 files/charm/wordpress/advanced-cache.php $wp_install_path/wp-content/advanced-cache.php |
Why are you removing php-memcache from the install hook? That's required for memcache to work within php