@@ -11,57 +11,40 @@ working WordPress project for the
11
11
* Install [ Composer] [ composer ]
12
12
* Create a new Cloud Project using the [ Cloud Console] [ cloud-console ]
13
13
* 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 ]
16
15
* 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 ]
20
18
21
19
## Project preparation
22
20
23
- Configure Google Cloud SDK with your account and the Project.
21
+ Configure Google Cloud SDK with your account and the appropriate project ID:
24
22
25
23
```
26
- $ gcloud auth login
27
- ...
28
- ...
29
- $ gcloud config set project YOUR_PROJECT_ID
24
+ $ gcloud init
30
25
```
31
26
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:
36
28
37
29
```
38
- $ gsutil defacl ch -u AllUsers:R gs://YOUR_PROJECT_ID.appspot.com
30
+ $ gcloud app create
39
31
```
40
32
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:
56
36
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
+ ```
60
40
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
62
42
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:
65
48
66
49
```
67
50
$ gcloud sql instances create wp \
@@ -72,38 +55,38 @@ $ gcloud sql instances create wp \
72
55
Then change the root password for your instance:
73
56
74
57
```
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!
77
60
```
78
61
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.
82
64
83
65
If you haven’t created a service account for the project,
84
66
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.
87
71
88
72
Run the proxy by the following command:
89
73
90
74
```
91
75
$ cloud_sql_proxy \
92
76
-dir /tmp/cloudsql \
93
77
-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
95
79
```
96
80
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:
99
83
100
84
```
101
85
$ mysql -h 127.0.0.1 -u root -p
102
86
mysql> create database wp;
103
87
mysql> create user 'wp'@'%' identified by 'PASSWORD'; // Don't use this password!
104
88
mysql> grant all on wp.* to 'wp'@'%';
105
89
mysql> exit
106
- Bye
107
90
```
108
91
109
92
## How to use
@@ -115,71 +98,53 @@ $ composer install
115
98
```
116
99
117
100
If it complains about extensions, please install ` phar ` and ` zip ` PHP
118
- extesions and retry.
101
+ extensions and retry.
119
102
120
103
Then run the helper command.
121
104
122
105
```
123
106
$ php wordpress-helper.php setup
124
107
```
125
108
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.
151
112
152
113
## Deployment
153
114
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:
155
117
156
118
```
119
+ $ cd my-wordpress-project
157
120
$ gcloud app deploy \
158
121
--promote --stop-previous-version app.yaml cron.yaml
159
122
```
160
123
161
124
Then access your site, and continue the installation step. The URL is:
162
125
https://PROJECT_ID.appspot.com/
163
126
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
165
128
plugins:
166
129
167
130
168
131
- For the standard environment
169
- - App Engine WordPress plugin (also set the e-mail address in its
170
- settings page)
171
132
- Batcache Manager
133
+ - Google App Engine for WordPress (also set the e-mail address in its
134
+ settings page)
172
135
- For the flexible environment
173
136
- Batcache Manager
174
137
- GCS media plugin
175
138
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 ] .
178
142
179
143
## Check if the Batcache plugin is working
180
144
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 ` .
183
148
184
149
To make sure it’s really working, you can open an incognito window and
185
150
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.
189
154
190
155
## Various workflows
191
156
192
- ### Install/Update plugins/ themes
157
+ ### Install/Update Wordpress, plugins, and themes
193
158
194
159
Because the wp-content directory on the server is read-only, you have
195
160
to do this locally. Run WordPress locally and update plugins/themes in
196
161
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):
198
164
199
165
```
166
+ # To update Wordpress itself
167
+ $ vendor/bin/wp core update --path=wordpress
200
168
# To update all the plugins
201
169
$ vendor/bin/wp plugin update --all --path=wordpress
202
170
# To update all the themes
@@ -209,13 +177,6 @@ First Deactivate them in the production Dashboard, then remove them
209
177
completely locally. The next deployment will remove those files from
210
178
the production environment.
211
179
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
-
219
180
### Update the base image
220
181
221
182
We sometimes release a security update for
@@ -228,11 +189,14 @@ Enjoy your WordPress installation!
228
189
[ appengine-flexible ] : https://cloud.google.com/appengine/docs/flexible/
229
190
[ sql-settings ] : https://console.cloud.google.com/sql/instances
230
191
[ 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
231
194
[ composer ] : https://getcomposer.org/
232
195
[ cloud-console ] : https://console.cloud.google.com/
196
+ [ cloud-storage-console ] : https://www.console.cloud.google.com/storage
233
197
[ cloud-sql-api-enable ] : https://console.cloud.google.com/flows/enableapi?apiid=sqladmin
234
198
[ app-engine-setting ] : https://console.cloud.google.com/appengine/settings
235
199
[ 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
237
201
[ credentials-section ] : https://console.cloud.google.com/apis/credentials/
238
202
[ php-docker ] : https://github.com/googlecloudplatform/php-docker
0 commit comments