Skip to content

Commit b78b56a

Browse files
authored
Merge pull request GoogleCloudPlatform#443 from GoogleCloudPlatform/wordpress-standard-README-improvements-2
WordPress on App Engine README Fixes + Improvements (ready for review + merge)
2 parents 46d6565 + fb415ab commit b78b56a

File tree

2 files changed

+56
-92
lines changed

2 files changed

+56
-92
lines changed

appengine/wordpress/README.md

Lines changed: 55 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -11,57 +11,40 @@ working WordPress project for the
1111
* Install [Composer][composer]
1212
* Create a new Cloud Project using the [Cloud Console][cloud-console]
1313
* Enable Billing on that project
14-
* [Enable Cloud SQL API][cloud-sql-api-enable] (For App Engine flexible environment)
15-
* Create App Engine default bucket at [App Engine Settings Page][app-engine-setting]
14+
* [Enable Cloud SQL API][cloud-sql-api-enable]
1615
* Install [Google Cloud SDK][gcloud-sdk]
17-
18-
## Prerequisites for standard environment only
19-
* Install mysql
16+
* Install the [mysql-client][mysql-client] command line tool
17+
* [Install Memcache][memcache-installation]
2018

2119
## Project preparation
2220

23-
Configure Google Cloud SDK with your account and the Project.
21+
Configure Google Cloud SDK with your account and the appropriate project ID:
2422

2523
```
26-
$ gcloud auth login
27-
...
28-
...
29-
$ gcloud config set project YOUR_PROJECT_ID
24+
$ gcloud init
3025
```
3126

32-
Then configure the App Engine default GCS bucket for later use. The
33-
default App Engine bucket looks like
34-
YOUR_PROJECT_ID.appspot.com. Change the default acl of that bucket as
35-
follows:
27+
Create an App Engine application within your new project:
3628

3729
```
38-
$ gsutil defacl ch -u AllUsers:R gs://YOUR_PROJECT_ID.appspot.com
30+
$ gcloud app create
3931
```
4032

41-
## Create and configure a Cloud SQL instance
42-
43-
If you will use the App Engine flexible environment, create a Cloud SQL
44-
2nd generation instance, and if you will use the App Engine standard
45-
environment, create a Cloud SQL 1st generation instance.
46-
47-
In this guide, we use `wp` for various resource names: the instance
48-
name, the database name, and the user name.
49-
50-
### Create and configure a Cloud SQL 1st generation instance (for the standard environment)
51-
52-
Go to the [SQL settings in the Cloud Console][sql-settings] and create
53-
an instance `wp` and database named `wp`. Go to the Access Control ->
54-
Users, then change the password for `root@localhost`. You will use
55-
this password for accessing Cloud SQL from your App Engine application.
33+
Then configure the App Engine default GCS bucket for later use. The default App
34+
Engine bucket is named YOUR_PROJECT_ID.appspot.com. Change the default Access
35+
Control List (ACL) of that bucket as follows:
5636

57-
Also create the `wp` database in the local mysql server. The local
58-
mysql instance is required to run the `wp-cli` tool for
59-
installing/upgrading plugins and themes.
37+
```
38+
$ gsutil defacl ch -u AllUsers:R gs://YOUR_PROJECT_ID.appspot.com
39+
```
6040

61-
### Create and configure a Cloud SQL 2nd generation instance (for the flexible environment)
41+
### Create and configure a Cloud SQL for MySQL 2nd generation instance
6242

63-
You can create a new Cloud SQL Second Generation instance with the
64-
following command:
43+
Note: In this guide, we use `wp` for various resource names; the instance
44+
name, the database name, and the user name.
45+
46+
Create a new Cloud SQL for MySQL Second Generation instance with the following
47+
command:
6548

6649
```
6750
$ gcloud sql instances create wp \
@@ -72,38 +55,38 @@ $ gcloud sql instances create wp \
7255
Then change the root password for your instance:
7356

7457
```
75-
$ gcloud sql instances set-root-password wp \
76-
--password YOUR_INSTANCE_ROOT_PASSWORD # Don't use this password!
58+
$ gcloud sql users set-password root % \
59+
--instance wp --password=YOUR_INSTANCE_ROOT_PASSWORD # Don't use this password!
7760
```
7861

79-
To access this MySQL instance, use Cloud SQL Proxy.
80-
Download an appropriate binary from
81-
[the download page][cloud-sql-proxy-download] and make it executable.
62+
To access this MySQL instance, use Cloud SQL Proxy. [Download][cloud-sql-proxy-download]
63+
it to your local computer and make it executable.
8264

8365
If you haven’t created a service account for the project,
8466
create it on [the Credentials section][credentials-section] in the
85-
Console (Choose a new service account). Download the JSON key file and
86-
save it in a secure place.
67+
Console. Click 'Create credentials' and then click 'Service account key.' For
68+
the Service account, select 'App Engine app default service account.' Then
69+
click 'Create' to create and download the JSON service account key to your
70+
local machine. Save it to a safe place.
8771

8872
Run the proxy by the following command:
8973

9074
```
9175
$ cloud_sql_proxy \
9276
-dir /tmp/cloudsql \
9377
-instances=YOUR_PROJECT_ID:us-central1:wp=tcp:3306 \
94-
-credential_file=PATH_TO_YOUR_SERVICE_ACCOUNT_JSON
78+
-credential_file=PATH_TO_YOUR_SERVICE_ACCOUNT_JSON_FILE
9579
```
9680

97-
Now you can access the Cloud SQL instance with the normal MySQL
98-
client. Create a new database and a user as follows:
81+
Now you can access the Cloud SQL instance with the MySQL client in a separate
82+
command line tab. Create a new database and a user as follows:
9983

10084
```
10185
$ mysql -h 127.0.0.1 -u root -p
10286
mysql> create database wp;
10387
mysql> create user 'wp'@'%' identified by 'PASSWORD'; // Don't use this password!
10488
mysql> grant all on wp.* to 'wp'@'%';
10589
mysql> exit
106-
Bye
10790
```
10891

10992
## How to use
@@ -115,71 +98,53 @@ $ composer install
11598
```
11699

117100
If it complains about extensions, please install `phar` and `zip` PHP
118-
extesions and retry.
101+
extensions and retry.
119102

120103
Then run the helper command.
121104

122105
```
123106
$ php wordpress-helper.php setup
124107
```
125108

126-
The command asks you several questions, please answer them. Then
127-
you'll have a new WordPress project. By default it will create
128-
`my-wordpress-project` in the current directory.
129-
130-
## Run WordPress locally and create a new user (for standard environment)
131-
132-
If you chose the flexible environment, skip this step.
133-
134-
This step will create a basic database setup in your local mysql
135-
server. This is required to use `wp-cli` tool.
136-
137-
CD into your WordPress project directory and run the following command
138-
to run WordPress locally (be sure to keep the cloud SQL proxy
139-
running):
140-
141-
```
142-
$ cd my-wordpress-project
143-
$ vendor/bin/wp(.bat) server --path=wordpress
144-
```
145-
146-
Then access http://localhost:8080/. Follow the installation steps,
147-
create the admin user and its password. Login to the Dashboard and
148-
update if any of the plugins have updates.
149-
150-
Now it’s ready for the first deployment.
109+
The command asks you several questions, please answer them. Then you'll have a
110+
new WordPress project. By default it will create `my-wordpress-project` in the
111+
current directory.
151112

152113
## Deployment
153114

154-
You can deploy your WordPress project by the following command.
115+
CD into your WordPress project directory and run the following command to
116+
deploy:
155117

156118
```
119+
$ cd my-wordpress-project
157120
$ gcloud app deploy \
158121
--promote --stop-previous-version app.yaml cron.yaml
159122
```
160123

161124
Then access your site, and continue the installation step. The URL is:
162125
https://PROJECT_ID.appspot.com/
163126

164-
Go to the Dashboard. On the Plugins page, activate the following
127+
Go to the Dashboard at https://PROJECT_ID.appspot.com/wp-admin. On the Plugins page, activate the following
165128
plugins:
166129

167130

168131
- For the standard environment
169-
- App Engine WordPress plugin (also set the e-mail address in its
170-
settings page)
171132
- Batcache Manager
133+
- Google App Engine for WordPress (also set the e-mail address in its
134+
settings page)
172135
- For the flexible environment
173136
- Batcache Manager
174137
- GCS media plugin
175138

176-
After activating the plugins, try uploading a media and confirm the
177-
image is uploaded to the GCS bucket.
139+
After activating the plugins, try uploading a media object in a new post
140+
and confirm the image is uploaded to the GCS bucket by visiting the
141+
[Google Cloud console's Storage page][cloud-storage-console].
178142

179143
## Check if the Batcache plugin is working
180144

181-
On the plugin page in the WordPress dashboard, you should see 2
182-
drop-ins are activated; `advanced-cache.php` and `object-cache.php`.
145+
On the plugin page in the WordPress dashboard, click on the Drop-ins tab near
146+
the top. You should see 2 drop-ins are activated: `advanced-cache.php` and
147+
`object-cache.php`.
183148

184149
To make sure it’s really working, you can open an incognito window and
185150
visit the site because the cache plugin only serves from cache to
@@ -189,14 +154,17 @@ check the hit ratio and number of items in cache.
189154

190155
## Various workflows
191156

192-
### Install/Update plugins/themes
157+
### Install/Update Wordpress, plugins, and themes
193158

194159
Because the wp-content directory on the server is read-only, you have
195160
to do this locally. Run WordPress locally and update plugins/themes in
196161
the local Dashboard, then deploy, then activate them in the production
197-
Dashboard. You can also use the `wp-cli` utility as follows:
162+
Dashboard. You can also use the `wp-cli` utility as follows (be sure to keep
163+
the cloud SQL proxy running):
198164

199165
```
166+
# To update Wordpress itself
167+
$ vendor/bin/wp core update --path=wordpress
200168
# To update all the plugins
201169
$ vendor/bin/wp plugin update --all --path=wordpress
202170
# To update all the themes
@@ -209,13 +177,6 @@ First Deactivate them in the production Dashboard, then remove them
209177
completely locally. The next deployment will remove those files from
210178
the production environment.
211179

212-
### Update WordPress itself
213-
214-
Most of the case, just download the newest WordPress and overwrite the
215-
existing wordpress directory. It is still possible that the existing
216-
config files are not compatible with the newest WordPress, so please
217-
update the config file manually in that case.
218-
219180
### Update the base image
220181

221182
We sometimes release a security update for
@@ -228,11 +189,14 @@ Enjoy your WordPress installation!
228189
[appengine-flexible]: https://cloud.google.com/appengine/docs/flexible/
229190
[sql-settings]: https://console.cloud.google.com/sql/instances
230191
[memcache-dashboard]: https://console.cloud.google.com/appengine/memcache
192+
[memcache-installation]: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-memcache-on-ubuntu-12-04#install-memcache
193+
[mysql-client]: https://dev.mysql.com/doc/refman/5.7/en/mysql.html
231194
[composer]: https://getcomposer.org/
232195
[cloud-console]: https://console.cloud.google.com/
196+
[cloud-storage-console]: https://www.console.cloud.google.com/storage
233197
[cloud-sql-api-enable]: https://console.cloud.google.com/flows/enableapi?apiid=sqladmin
234198
[app-engine-setting]: https://console.cloud.google.com/appengine/settings
235199
[gcloud-sdk]: https://cloud.google.com/sdk/
236-
[cloud-sql-proxy-download]: https://cloud.google.com/sql/docs/external#appaccess
200+
[cloud-sql-proxy-download]: https://cloud.google.com/sql/docs/mysql/connect-external-app#install
237201
[credentials-section]: https://console.cloud.google.com/apis/credentials/
238202
[php-docker]: https://github.com/googlecloudplatform/php-docker

appengine/wordpress/src/WordPressSetup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class WordPressSetup extends Command
2929
{
3030
const DEFAULT_DIR = 'my-wordpress-project';
3131
const DEFAULT_ERROR = 1;
32-
const LATEST_WP = 'https://wordpress.org/latest.tar.gz';
32+
const LATEST_WP = 'https://wordpress.org/4.8.1.tar.gz';
3333
const LATEST_BATCACHE =
3434
'https://downloads.wordpress.org/plugin/batcache.1.4.zip';
3535
const LATEST_MEMCACHED =

0 commit comments

Comments
 (0)