Merge lp:~jose/charms/precise/wordpress/fix-1309980 into lp:charms/wordpress

Proposed by José Antonio Rey
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
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
Matt Bruzek (community) Needs Fixing
Review via email: mp+216568@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

Why are you removing php-memcache from the install hook? That's required for memcache to work within php

Revision history for this message
José Antonio Rey (jose) wrote :

It's doubled if you check correctly.

Revision history for this message
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/wordpress
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:
        agent-state: error
        agent-state-info: 'hook failed: "cache-relation-changed"'
The log indicates:
sed: can't read /var/www/wp-content/plugins/wp-ffpc/wp-ffpc.php: No such file or directory

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-changed sed: can't read /var/www/wp-content/plugins/wp-ffpc/wp-ffpc.php: No such file or directory
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!

Revision history for this message
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.

review: Needs Fixing
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README.md'
--- README.md 2013-12-12 18:42:27 +0000
+++ README.md 2014-06-30 21:18:30 +0000
@@ -1,12 +1,16 @@
1# Overview1# Overview
22
3WordPress 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 out3WordPress is a powerful blogging platform written in PHP. This charm aims to
4a single installation.4deploy WordPress in a fashion that will allow anyone to scale and grow out a
5single installation.
56
6# Usage7# Usage
78
8This charm is available in the Juju Charm Store, to deploy you'll need at a minimum: a cloud environment, a working Juju installation,9This charm is available in the Juju Charm Store, to deploy you'll need at a
9and a successful bootstrap. Please refer to the [Juju Getting Started](https://juju.ubuntu.com/docs/getting-started.html) documentation before continuing.10minimum: a cloud environment, a working Juju installation, and a successful
11bootstrap. Please refer to the
12[Juju Getting Started](https://juju.ubuntu.com/docs/getting-started.html)
13documentation before continuing.
1014
11Once bootstrapped, deploy the MySQL charm then this WordPress charm:15Once bootstrapped, deploy the MySQL charm then this WordPress charm:
1216
@@ -23,7 +27,9 @@
2327
24## Scaled Down Usage for Personal Use28## Scaled Down Usage for Personal Use
2529
26If 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: 30If you're just looking to run a personal blog and want to save money you can run
31all of this on a single node, here's an entire single node installation from
32scratch:
2733
28 juju bootstrap34 juju bootstrap
29 juju deploy --to 0 wordpress35 juju deploy --to 0 wordpress
@@ -31,40 +37,59 @@
31 juju add-relation wordpress mysql 37 juju add-relation wordpress mysql
32 juju expose wordpress38 juju expose wordpress
3339
34This 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:40This will run everything on one node, however we still have the flexibility to
41grow horizontally. If your blog gets more traffic and you need to scale:
3542
36 juju add-unit wordpress43 juju add-unit wordpress
3744
38Since 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. 45Since we're omitting the `--to` command Juju will fire up a new dedicated
46machine for Wordpress and relate it. You can also `remove-unit` when the surge
47is over and go back to a cheaper one node set up.
3948
40# Scale Out Usage 49# Scale Out Usage
4150
42You can deploy a memcached server and relate it to your WordPress service to add memcache caching. This will 51You can deploy a memcached server and relate it to your WordPress service to add
43automagically install [WP-FFPC](http://wordpress.org/extend/plugins/wp-ffpc/) (regardless of your tuning settings) and configure it to cache 52memcache caching. This will automagically install
44rendered pages to the memcache server. In addition to this layer of caching, Nginx will pull directly from memcached bypassing PHP altogether. 53[WP-FFPC](http://wordpress.org/extend/plugins/wp-ffpc/) (regardless of your
45You could theoretically then turn off php5-fpm on all of your servers and just have Nginx serve static content via memcached (though, you 54tuning settings) and configure it to cache rendered pages to the memcache
46wouldn't be able to access the admin panel or any uncached pages - it's just a potential scenario).55server. In addition to this layer of caching, Nginx will pull directly from
56memcached bypassing PHP altogether. You could theoretically then turn off
57php5-fpm on all of your servers and just have Nginx serve static content via
58memcached (though, you wouldn't be able to access the admin panel or any
59uncached pages - it's just a potential scenario).
4760
48 juju deploy memcached61 juju deploy memcached
49 juju add-relation memcached wordpress62 juju add-relation memcached wordpress
50 63
51This setup will also synchronize the flushing of cache across all WordPress nodes, making it ideal to avoid stale caches.64This setup will also synchronize the flushing of cache across all WordPress
5265nodes, making it ideal to avoid stale caches.
53A small note, when using the Apache2 engine and memcache, all request will still be sent to WordPress via Apache where typical caching 66
54procedures will take place and wp-ffpc will render the memcached page.67Once the relation is set and the hooks have ran accordingly, you will need to
68manually save the settings for WP-FFPC. Everything will be configured, though.
69Just log in to the administrator Dashboard, and then click the link to the
70WP-FFPC Settings page displayed on the error at the top of the page. Finally,
71scroll down and click on the blue button which says Save Changes.
72
73A small note, when using the Apache2 engine and memcache, all request will
74still be sent to WordPress via Apache where typical caching procedures will take
75place and wp-ffpc will render the memcached page.
5576
56# Configuration77# Configuration
5778
58This WordPress charm comes with several tuning levels designed to encompass the different styles in which this charm will be used.79This WordPress charm comes with several tuning levels designed to encompass the
80different styles in which this charm will be used.
5981
60A use case for each tuning style is outlined below:82A use case for each tuning style is outlined below:
6183
62## Bare84## Bare
6385
64The Bare configuration option is meant for those who wish to run the stock WordPress setup with no caching, no manipulation of data, 86The Bare configuration option is meant for those who wish to run the stock
65and no additional scale out features enabled. This is ideal if you intend to install additional plugins to deal with coordinating87WordPress setup with no caching, no manipulation of data, and no additional
66WordPress units or simply wish to test drive WordPress as it is out of the box. This will still create a load-balancer when an additional88scale out features enabled. This is ideal if you intend to install additional
67unit is created, though everything else will be turned off (WordPress caching, APC OpCode caching, and NFS file sharing).89plugins to deal with coordinating WordPress units or simply wish to test drive
90WordPress as it is out of the box. This will still create a load-balancer when
91an additional unit is created, though everything else will be turned off
92(WordPress caching, APC OpCode caching, and NFS file sharing).
6893
69To run this WordPress charm under a bare tuning level execute the following:94To run this WordPress charm under a bare tuning level execute the following:
7095
@@ -72,11 +97,14 @@
7297
73## Single98## Single
7499
75When running in Single mode, this charm will make every attempt to provide a solid base for your WordPress install. By running in single100When running in Single mode, this charm will make every attempt to provide a
76the following will be enabled: Nginx microcache, APC OpCode caching, WordPress caching module, and the ability to sync files via NFS.101solid base for your WordPress install. By running in single the following will
77While 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 large102be enabled: Nginx microcache, APC OpCode caching, WordPress caching module,
78traffic in-flux. It's recommended for long running scaled out versions that optimized is used. The removal of the file share speeds up103and the ability to sync files via NFS. While Single mode is designed to allow
79the site and servers ensuring that the most efficient set up is provided. 104for scaling out, it's meant to only scale out for temporary relief; say in the
105event of a large traffic in-flux. It's recommended for long running scaled out
106versions that optimized is used. The removal of the file share speeds up the
107site and servers ensuring that the most efficient set up is provided.
80108
81To run this WordPress charm under a single tuning level execute the following:109To run this WordPress charm under a single tuning level execute the following:
82110
@@ -84,21 +112,29 @@
84112
85## Optimized113## Optimized
86114
87If you need to run WordPress on more than one instance constantly, or require scaling out and in on a regular basis, then Optimized is the115If you need to run WordPress on more than one instance constantly, or require
88recommended configuration. When you run WordPress under an Optimized tuning level, the ability to install, edit, and upgrade themes and plugins116scaling out and in on a regular basis, then Optimized is the recommended
89is 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.117configuration. When you run WordPress under an Optimized tuning level, the
90Everything else provided in Single level is available. In order to install or modify plugins with this setup you'll need to edit and commit118ability to install, edit, and upgrade themes and plugins is disabled. By doing
91them to a forked version of the charm in the files/wordpress/ directory.119this the charm can drop the need for an NFS mount which is inefficient and serve
120everything from it's local disk. Everything else provided in Single level is
121available. In order to install or modify plugins with this setup you'll need to
122edit and commit them to a forked version of the charm in the files/wordpress/
123directory.
92124
93To run this WordPress charm under an optimized tuning level execute the following:125To run this WordPress charm under an optimized tuning level execute the
126following:
94127
95 juju set wordpress tuning=optimized128 juju set wordpress tuning=optimized
96129
97### Handling wp-content130### Handling wp-content
98131
99In order to allow for custom WordPress content within the Juju charm a separate configuration option exists for pointing to any Git or Bzr 132In order to allow for custom WordPress content within the Juju charm a separate
100repository. An example of a valid formed wp-content repository can be found on the [Juju Tools Github page](https://github.com/jujutools/wordpress-site). 133configuration option exists for pointing to any Git or Bzr repository. An
101To 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 134example of a valid formed wp-content repository can be found on the
135[Juju Tools Github page](https://github.com/jujutools/wordpress-site). To set
136the wp-content directive to a git repository, use one of the following formats
137making sure to replace items like `host`, `path`, and `repo` with their
102respective names:138respective names:
103139
104 juju set wordpress wp-content=git@host:path/repo.git140 juju set wordpress wp-content=git@host:path/repo.git
@@ -111,7 +147,9 @@
111147
112 juju set wordpress wp-content=git://host/path/repo.git148 juju set wordpress wp-content=git://host/path/repo.git
113 149
114If 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:150If you wish to use a bzr repository, then apply one of the following schemes
151replacing items like `host`, `username`, `path`, and `repo` with their
152respective values:
115153
116For LaunchPad hosted repostiories:154For LaunchPad hosted repostiories:
117155
@@ -125,15 +163,20 @@
125163
126 juju set wordpress wp-content=bzr+ssh://host/path/repo164 juju set wordpress wp-content=bzr+ssh://host/path/repo
127 165
128Setting 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 166Setting the wp-content option to an empty string ("") will result in no further
129on the system and will not be removed.167updates being pulled from that repository; however, the last pull will remain on
168the system and will not be removed.
130169
131## debug170## debug
132171
133This 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`) 172This option will create a directory `_debug` at the root of each unit
134and 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 173(`http://unit-address/_debug`). In this directory are two scripts: info.php
135provides 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 174(`/_debug/info.php`) and apc.php (`/_debug/apc.php`). info.php is a simple
136detailed information about the environments and may provide a way for an intruder to DDoS the machine.175phpinfo script that will outline exactly how the environment is configured.
176apc.php is the APC admin portal which provides APC caching details in addition
177to several administrative functions like clearing the APC cache. This should
178never be set to "yes" in production as it exposes detailed information about the
179environments and may provide a way for an intruder to DDoS the machine.
137180
138 juju set wordpress debug=yes181 juju set wordpress debug=yes
139182
@@ -145,10 +188,15 @@
145188
146## Engine189## Engine
147190
148By 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.191By default the WordPress charm will install nginx and php5-fpm to serve pages.
149This 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 to192In the event you do not wish to use nginx - for whatever reason - you can switch
150hitting 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.193to Apache2. This will provide a near identical workflow as if you were using
151Otherwise, Apache2 will still perform balancing and everything else mentioned above. You can switch between engines at will with the following:194nginx with one key difference: memcached. In nginx, the cached pages are served
195from memcached prior to hitting the php contents, this isn't possible with
196apache2. As such memcached support still works, since it falls back to the
197WordPress caching engine, but it's not as robust. Otherwise, Apache2 will still
198perform balancing and everything else mentioned above. You can switch between
199engines at will with the following:
152200
153 juju set wordpress engine=apache2201 juju set wordpress engine=apache2
154202
@@ -162,38 +210,54 @@
162210
163## HP Cloud 211## HP Cloud
164212
165At this time WordPress + Memcached don't work on HP Cloud's standard.xsmall. To get around this deploy the WordPress charm with the 213At this time WordPress + Memcached don't work on HP Cloud's standard.xsmall. To
166charm to at least a `standard.small`, to do this:214get around this deploy the WordPress charm with the charm to at least a
215`standard.small`, to do this:
167216
168 juju deploy --constraints "instance-type=standard.small" wordpress217 juju deploy --constraints "instance-type=standard.small" wordpress
169218
170This only is a problem when attempting to relate memcached to WordPress, otherwise an xsmall is _okay_ though it's really not the best 219This only is a problem when attempting to relate memcached to WordPress,
171sized platform for running a stable WordPress install.220otherwise an xsmall is _okay_ though it's really not the best sized platform for
221running a stable WordPress install.
172222
173## Single mode and the scale-out223## Single mode and the scale-out
174224
175If you're in Single mode and you want to/need to scale out, but you've been upgrading, modifying, and installing plugins + themes like225If you're in Single mode and you want to/need to scale out, but you've been
176a 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 of226upgrading, modifying, and installing plugins + themes like a normal WordPress
177this writing only the NFS charm will work, but as more shared-fs charms come out (gluster, ceph, etc) that provide a shared-fs/mount 227user on a normal install; you can still scale out but you'll need to deploy a
178interface those should all work as well. In this example we'll use NFS:228shared-fs charm first. At the time of this writing only the NFS charm will work,
229but as more shared-fs charms come out (gluster, ceph, etc) that provide a
230shared-fs/mount interface those should all work as well. In this example we'll
231use NFS:
179232
180 juju deploy nfs233 juju deploy nfs
181 juju add-relation nfs wordpress:nfs234 juju add-relation nfs wordpress:nfs
182235
183By doing so, everything in the wp-contents directory is moved to this NFS mount and then shared to all future WordPress units. It's strongly236By doing so, everything in the wp-contents directory is moved to this NFS mount
184recommended that you first deploy the nfs mount, _then_ scale WordPress out. Failure to do so may result in data loss. Once nfs is deployed, 237and then shared to all future WordPress units. It's strongly recommended that
185running, and related you can scale out the WordPress unit using the following command:238you first deploy the nfs mount, _then_ scale WordPress out. Failure to do so may
239result in data loss. Once nfs is deployed, running, and related you can scale
240out the WordPress unit using the following command:
186241
187 juju add-unit wordpress242 juju add-unit wordpress
188 243
189In 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` number244In the event you want more than one unit at a time (and do not wish to run the
190of units to add, so to add three more units:245add-unit command multiple times) you can supply a `-n` number of units to add,
246so to add three more units:
191247
192 juju add-unit -n3 wordpress248 juju add-unit -n3 wordpress
193249
250## Memcached Issues
251
252In order to have a working relation with memcached, you need to first set up
253your Wordpress blog, by creating your first user. If you try to relate
254memcached before, you will get a `cache-relation-changed` error on your
255instance.
256
194# Contact Information257# Contact Information
195258
196## WordPress Contact Information259## WordPress Contact Information
197260
198- [WordPress Homepage](http://www.wordpress.org)261- [WordPress Homepage](http://www.wordpress.org)
199- [Reporting bugs](http://codex.wordpress.org/Reporting_Bugs) on WordPress itself
200\ No newline at end of file262\ No newline at end of file
263- [Reporting bugs](http://codex.wordpress.org/Reporting_Bugs) on WordPress
264itself
201265
=== modified file 'hooks/cache-relation-changed'
--- hooks/cache-relation-changed 2012-08-24 20:59:04 +0000
+++ hooks/cache-relation-changed 2014-06-30 21:18:30 +0000
@@ -6,6 +6,11 @@
66
7rm -f .memcache7rm -f .memcache
88
9if [ -z $memcache_port ]; then
10 juju-log "Info hasn't been received from the instance yet, exiting silently"
11 exit 0
12fi
13
9cat > .memcache <<EOF14cat > .memcache <<EOF
10#!/bin/bash15#!/bin/bash
11CACHE_HOST=$memcache_host16CACHE_HOST=$memcache_host
1217
=== modified file 'hooks/install'
--- hooks/install 2013-09-27 18:31:24 +0000
+++ hooks/install 2014-06-30 21:18:30 +0000
@@ -6,8 +6,8 @@
6apt-get update && apt-get -y upgrade6apt-get update && apt-get -y upgrade
77
8apt-get -y install php5-memcache mysql-client pwgen php5 php5-fpm \8apt-get -y install php5-memcache mysql-client pwgen php5 php5-fpm \
9 php-apc mailutils php-mail sysstat php5-mysql php5-mcrypt php5-memcache \9 php-apc mailutils php-mail sysstat php5-mysql php5-mcrypt charm-helper-sh \
10 charm-helper-sh php5-curl rsync nfs-common git-core mktemp10 php5-curl rsync nfs-common git-core mktemp
1111
12modprobe nfs || true12modprobe nfs || true
1313
1414
=== modified file 'inc/common'
--- inc/common 2013-09-19 12:18:50 +0000
+++ inc/common 2014-06-30 21:18:30 +0000
@@ -200,7 +200,8 @@
200 source .memcache200 source .memcache
201201
202 wp plugin install --path=$wp_install_path wp-ffpc202 wp plugin install --path=$wp_install_path wp-ffpc
203 sed -i -e "s/'host'=>.*/'host'=>'$CACHE_HOST',/" $wp_install_path/wp-content/plugins/wp-ffpc/wp-ffpc.php203 sed -i -e "s/'hosts'=>.*/'hosts'=>'$CACHE_HOST:$CACHE_PORT',/" $wp_install_path/wp-content/plugins/wp-ffpc/wp-ffpc.php
204 sed -i "s/memcached/memcache/g" $wp_install_path/wp-content/plugins/wp-ffpc/wp-ffpc.php
204 wp plugin activate --path=$wp_install_path wp-ffpc205 wp plugin activate --path=$wp_install_path wp-ffpc
205206
206 install -o www-data -g www-data -m 0644 files/charm/wordpress/advanced-cache.php $wp_install_path/wp-content/advanced-cache.php207 install -o www-data -g www-data -m 0644 files/charm/wordpress/advanced-cache.php $wp_install_path/wp-content/advanced-cache.php

Subscribers

People subscribed via source and target branches

to all changes: