2
2
3
3
This is a small command line tool for downloading and configuring
4
4
WordPress for Google Cloud Platform. The script allows you to create a
5
- working WordPress project for
6
- [ App Engine standard environment] [ appengine-standard ] or
5
+ working WordPress project for the
6
+ [ App Engine standard environment] [ appengine-standard ] or the
7
7
[ App Engine flexible environment] [ appengine-flexible ] .
8
8
9
9
## Common Prerequisites
10
10
11
11
* Install [ Composer] [ composer ]
12
- * Create a new Cloud Project on [ Developers Console] [ dev -console]
12
+ * Create a new Cloud Project using the [ Cloud Console] [ cloud -console]
13
13
* Enable Billing on that project
14
14
* [ Enable Cloud SQL API] [ cloud-sql-api-enable ]
15
15
* Install [ Google Cloud SDK] [ gcloud-sdk ]
16
-
17
- ## Prerequisites for standard environment only
18
- * Install mysql
16
+ * [ Install mysql-client] [ mysql-client ]
17
+ * [ Install Memcache] [ memcache-installation ]
19
18
20
19
## Project preparation
21
20
@@ -31,22 +30,21 @@ Create an App Engine application within your new project:
31
30
$ gcloud app create
32
31
```
33
32
34
- Then configure the App Engine default GCS bucket for later use. The
35
- default App Engine bucket looks like
36
- YOUR_PROJECT_ID.appspot.com. Change the default acl of that bucket as
37
- follows:
33
+ Then configure the App Engine default GCS bucket for later use. The default App
34
+ Engine bucket looks like YOUR_PROJECT_ID.appspot.com. Change the default Access
35
+ Control List (ACL) of that bucket as follows:
38
36
39
37
```
40
38
$ gsutil defacl ch -u AllUsers:R gs://YOUR_PROJECT_ID.appspot.com
41
39
```
42
40
43
- ### Create and configure a Cloud SQL 2nd generation instance
41
+ ### Create and configure a Cloud SQL for MySQL 2nd generation instance
44
42
45
43
Note: In this guide, we use ` wp ` for various resource names; the instance
46
44
name, the database name, and the user name.
47
-
48
- You can create a new Cloud SQL Second Generation instance with the
49
- following command:
45
+
46
+ Create a new Cloud SQL for MySQL Second Generation instance with the following
47
+ command:
50
48
51
49
```
52
50
$ gcloud sql instances create wp \
@@ -61,11 +59,11 @@ $ gcloud sql users set-password root % \
61
59
--instance wp --password=YOUR_INSTANCE_ROOT_PASSWORD # Don't use this password!
62
60
```
63
61
64
- To access this MySQL instance, we’ll use Cloud SQL Proxy. Follow
65
- [ these instructions ] [ cloud-sql-proxy-download ] to install the Cloud SQL Proxy
66
- client on your local machine and make it executable.
62
+ To access this MySQL instance, use Cloud SQL Proxy.
63
+ Download an appropriate binary from
64
+ [ the download page ] [ cloud-sql-proxy-download ] and make it executable.
67
65
68
- If you haven’t created a service account for the project, please
66
+ If you haven’t created a service account for the project,
69
67
create it on [ the Credentials section] [ credentials-section ] in the
70
68
Console. Click 'Create credentials' and then click 'Service account key.' For
71
69
the Service account, select 'App Engine app default service account.' Then
@@ -78,23 +76,20 @@ Run the proxy by the following command:
78
76
$ cloud_sql_proxy \
79
77
-dir /tmp/cloudsql \
80
78
-instances=YOUR_PROJECT_ID:us-central1:wp=tcp:3306 \
81
- -credential_file=PATH_TO_YOUR_SERVICE_ACCOUNT_JSON
79
+ -credential_file=PATH_TO_YOUR_SERVICE_ACCOUNT_JSON_FILE
82
80
```
83
81
84
- Now you can access to the Cloud SQL instance with the normal MySQL
85
- client. Please create a new database and a user as follows:
82
+ Now you can access the Cloud SQL instance with the MySQL client. Create a new
83
+ database and a user as follows:
86
84
87
85
```
88
86
$ mysql -h 127.0.0.1 -u root -p
89
87
mysql> create database wp;
90
88
mysql> create user 'wp'@'%' identified by 'PASSWORD'; // Don't use this password!
91
89
mysql> grant all on wp.* to 'wp'@'%';
92
90
mysql> exit
93
- Bye
94
91
```
95
92
96
- In the above example, I created a new database wp and a new user wp.
97
-
98
93
## How to use
99
94
100
95
First install the dependencies in this directory as follows:
@@ -104,17 +99,17 @@ $ composer install
104
99
```
105
100
106
101
If it complains about extensions, please install ` phar ` and ` zip ` PHP
107
- extesions and retry.
102
+ extensions and retry.
108
103
109
104
Then run the helper command.
110
105
111
106
```
112
107
$ php wordpress-helper.php setup
113
108
```
114
109
115
- The command asks you several questions, please answer them. Then
116
- you'll have a new WordPress project. By default it will create
117
- ` my-wordpress-project ` in the current directory.
110
+ The command asks you several questions, please answer them. Then you'll have a
111
+ new WordPress project. By default it will create ` my-wordpress-project ` in the
112
+ current directory.
118
113
119
114
## Run WordPress locally and create a new user (for standard environment)
120
115
@@ -134,7 +129,7 @@ $ vendor/bin/wp server --path=wordpress
134
129
135
130
Then access http://localhost:8080/ . Follow the installation steps,
136
131
create the admin user and its password. Login to the Dashboard and
137
- update if any of the plugins have update .
132
+ update if any of the plugins have updates .
138
133
139
134
Now it’s ready for the first deployment.
140
135
@@ -150,25 +145,26 @@ $ gcloud app deploy \
150
145
Then access your site, and continue the installation step. The URL is:
151
146
https://PROJECT_ID.appspot.com/
152
147
153
- Go to the Dashboard, and in the Plugins page, activate the following
148
+ Go to the Dashboard at https://PROJECT_ID.appspot.com/wp-admin . On the Plugins page, activate the following
154
149
plugins:
155
150
156
151
157
- - For standard environment
158
- - App Engine WordPress plugin (also set the e-mail address in its
159
- setting page)
152
+ - For the standard environment
160
153
- Batcache Manager
161
- - For flexible environment
154
+ - Google App Engine for WordPress (also set the e-mail address in its
155
+ settings page)
156
+ - For the flexible environment
162
157
- Batcache Manager
163
158
- GCS media plugin
164
159
165
- After activating the plugins, try uploading a media and confirm the
166
- image is uploaded to the GCS bucket.
160
+ After activating the plugins, try uploading a media object in a new post
161
+ and confirm the image is uploaded to the GCS bucket by visiting the
162
+ [ Google Cloud console's Storage page] [ cloud-storage-console ] .
167
163
168
164
## Check if the Batcache plugin is working
169
165
170
- On the plugin page in the WordPress dashboard, you should see 2
171
- drop-ins are activated; ` advanced-cache.php ` and ` object-cache.php ` .
166
+ On the plugin page in the WordPress dashboard, click on the Drop-ins tab. You
167
+ should see 2 drop-ins are activated: ` advanced-cache.php ` and ` object-cache.php ` .
172
168
173
169
To make sure it’s really working, you can open an incognito window and
174
170
visit the site because the cache plugin only serves from cache to
@@ -178,14 +174,17 @@ check the hit ratio and number of items in cache.
178
174
179
175
## Various workflows
180
176
181
- ### Install/Update plugins/ themes
177
+ ### Install/Update Wordpress, plugins, and themes
182
178
183
179
Because the wp-content directory on the server is read-only, you have
184
180
to do this locally. Run WordPress locally and update plugins/themes in
185
181
the local Dashboard, then deploy, then activate them in the production
186
- Dashboard. You can also use the ` wp-cli ` utility as follows:
182
+ Dashboard. You can also use the ` wp-cli ` utility as follows (be sure to keep
183
+ the cloud SQL proxy running):
187
184
188
185
```
186
+ # To update Wordpress itself
187
+ $ vendor/bin/wp core update --path=wordpress
189
188
# To update all the plugins
190
189
$ vendor/bin/wp plugin update --all --path=wordpress
191
190
# To update all the themes
@@ -198,17 +197,10 @@ First Deactivate them in the production Dashboard, then remove them
198
197
completely locally. The next deployment will remove those files from
199
198
the production environment.
200
199
201
- ### Update WordPress itself
202
-
203
- Most of the case, just download the newest WordPress and overwrite the
204
- existing wordpress directory. It is still possible that the existing
205
- config files are not compatible with the newest WordPress, so please
206
- update the config file manually in that case.
207
-
208
200
### Update the base image
209
201
210
- We sometimes release the security update for
211
- [ the php-docker image] [ php-docker ] . Then you’ll have to re-deploy your
202
+ We sometimes release a security update for
203
+ [ the php-docker image] [ php-docker ] . You have to re-deploy your
212
204
WordPress instance to get the security update.
213
205
214
206
Enjoy your WordPress installation!
@@ -217,8 +209,11 @@ Enjoy your WordPress installation!
217
209
[ appengine-flexible ] : https://cloud.google.com/appengine/docs/flexible/
218
210
[ sql-settings ] : https://console.cloud.google.com/sql/instances
219
211
[ memcache-dashboard ] : https://console.cloud.google.com/appengine/memcache
212
+ [ memcache-installation ] : https://www.digitalocean.com/community/tutorials/how-to-install-and-use-memcache-on-ubuntu-12-04#install-memcache
213
+ [ mysql-client ] : https://dev.mysql.com/doc/refman/5.7/en/mysql.html
220
214
[ composer ] : https://getcomposer.org/
221
- [ dev-console ] : https://console.cloud.google.com/
215
+ [ cloud-console ] : https://console.cloud.google.com/
216
+ [ cloud-storage-console ] : https://www.console.cloud.google.com/storage
222
217
[ cloud-sql-api-enable ] : https://console.cloud.google.com/flows/enableapi?apiid=sqladmin
223
218
[ app-engine-setting ] : https://console.cloud.google.com/appengine/settings
224
219
[ gcloud-sdk ] : https://cloud.google.com/sdk/
0 commit comments