@@ -27,30 +27,24 @@ Instructions are provided below for using the proxy with a TCP connection or a
2727Unix domain socket. On Linux or macOS, you can use either option, but the
2828Windows proxy currently requires a TCP connection.
2929
30- ### Unix Socket mode
30+ ### Launch proxy with Unix Domain Socket
3131NOTE: this option is currently only supported on Linux and macOS. Windows users
3232should use the TCP option.
3333
3434To use a Unix socket, you'll need to create a directory and give write access to
3535the user running the proxy:
3636
3737``` bash
38- sudo mkdir /path/to/the/new/directory
39- sudo chown -R $USER /path/to/the/new/directory
40- ```
41-
42- You'll also need to initialize an environment variable pointing to the directory
43- you just created:
44-
45- ``` bash
46- export DB_SOCKET_DIR=/path/to/the/new/directory
38+ sudo mkdir /cloudsql
39+ sudo chown -R $USER /cloudsql
4740```
4841
4942Use these terminal commands to initialize other environment variables as well:
5043
5144``` bash
5245export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account/key.json
53- export INSTANCE_CONNECTION_NAME=' <MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>'
46+ export INSTANCE_CONNECTION_NAME=' <PROJECT-ID>:<INSTANCE-REGION>:<INSTANCE-NAME>'
47+ export INSTANCE_UNIX_SOCKET=' /cloudsql/<PROJECT-ID>:<INSTANCE-REGION>:<INSTANCE-NAME>'
5448export DB_USER=' <DB_USER_NAME>'
5549export DB_PASS=' <DB_PASSWORD>'
5650export DB_NAME=' <DB_NAME>'
@@ -64,20 +58,20 @@ safe.
6458Then use the following command to launch the proxy in the background:
6559
6660``` bash
67- ./cloud_sql_proxy -dir=$DB_SOCKET_DIR --instances=$INSTANCE_CONNECTION_NAME --credential_file=$GOOGLE_APPLICATION_CREDENTIALS &
61+ ./cloud_sql_proxy -dir=/cloudsql --instances=$INSTANCE_CONNECTION_NAME --credential_file=$GOOGLE_APPLICATION_CREDENTIALS &
6862```
6963
70- ### TCP mode
64+ ### Launch proxy with TCP
7165To run the sample locally with a TCP connection, set environment variables and
7266launch the proxy as shown below.
7367
74- #### Linux / macOS
68+ #### Linux / Mac OS
7569Use these terminal commands to initialize environment variables:
7670
7771``` bash
7872export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account/key.json
79- export INSTANCE_CONNECTION_NAME=' <MY- PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>'
80- export DB_HOST =' 127.0.0.1'
73+ export INSTANCE_CONNECTION_NAME=' <PROJECT-ID >:<INSTANCE-REGION>:<INSTANCE-NAME>'
74+ export INSTANCE_HOST =' 127.0.0.1'
8175export DB_USER=' <DB_USER_NAME>'
8276export DB_PASS=' <DB_PASSWORD>'
8377export DB_NAME=' <DB_NAME>'
@@ -99,7 +93,7 @@ Use these PowerShell commands to initialize environment variables:
9993
10094``` powershell
10195$env:GOOGLE_APPLICATION_CREDENTIALS="<CREDENTIALS_JSON_FILE>"
102- $env:DB_HOST ="127.0.0.1"
96+ $env:INSTANCE_HOST ="127.0.0.1"
10397$env:DB_USER="<DB_USER_NAME>"
10498$env:DB_PASS="<DB_PASSWORD>"
10599$env:DB_NAME="<DB_NAME>"
@@ -126,45 +120,52 @@ php -S localhost:8080
126120Navigate towards http://localhost:8080 to verify your application is running
127121correctly.
128122
123+ ## Google App Engine Standard
124+ Note: App Engine Standard does not support TCP connections to Cloud SQL
125+ instances, only Unix socket connections.
126+
127+ To run on GAE-Standard, create an App Engine project by following the setup for
128+ these
129+ [ instructions] ( https://cloud.google.com/appengine/docs/standard/php7/quickstart#before-you-begin ) .
130+
131+ First, update [ app.standard.yaml] ( app.standard.yaml ) with the correct values to pass the
132+ environment variables into the runtime.
133+
134+ Next, delete the ` composer.lock ` file if it exists. This will ensure that the sample app
135+ is built with the package versions specified in ` composer.json ` .
136+
137+ Next, the following command will deploy the application to your Google Cloud
138+ project:
139+
140+ ``` bash
141+ $ gcloud app deploy app.standard.yaml
142+ ```
143+
129144## Google App Engine Flex
130145To run on App Engine Flex, create an App Engine project by following the setup
131146for these
132147[ instructions] ( https://cloud.google.com/appengine/docs/standard/php7/quickstart#before-you-begin ) .
133148
134- First, update ` app.flex.yaml ` with the correct values to pass the environment
149+ First, update [ app.flex.yaml] ( app.flex.yaml ) with the correct values to pass the environment
135150variables into the runtime.
136151
137152To use a TCP connection instead of a Unix socket to connect your sample to your
138- Cloud SQL instance on App Engine, make sure to uncomment the ` DB_HOST `
153+ Cloud SQL instance on App Engine, make sure to uncomment the ` INSTANCE_HOST `
139154field under ` env_variables ` . Also make sure to remove the uncommented
140155` beta_settings ` and ` cloud_sql_instances ` fields and replace them with the
141156commented ` beta_settings ` and ` cloud_sql_instances ` fields.
142157
143- Then, make sure that the service account
144- ` service-{PROJECT_NUMBER}>@gae-api-prod.google.com.iam .gserviceaccount.com` has
158+ Then, make sure that the App Engine default service account
159+ ` <PROJECT-ID>@appspot .gserviceaccount.com` has
145160the IAM role ` Cloud SQL Client ` .
146161
147- Next, the following command will deploy the application to your Google Cloud
148- project:
149-
150- ``` bash
151- $ gcloud beta app deploy app.flex.yaml
152- ```
153-
154- ## Google App Engine Standard
155- Note: App Engine Standard does not support TCP connections to Cloud SQL
156- instances, only Unix socket connections.
157-
158- To run on GAE-Standard, create an App Engine project by following the setup for
159- these
160- [ instructions] ( https://cloud.google.com/appengine/docs/standard/php7/quickstart#before-you-begin ) .
161-
162- First, update ` app.standard.yaml ` with the correct values to pass the
163- environment variables into the runtime.
162+ Also, make sure that the Cloud Build service account
163+ ` cloudbuild@<PROJECT-ID>.iam.gserviceaccount.com ` has
164+ the IAM role ` Cloud SQL Client ` .
164165
165166Next, the following command will deploy the application to your Google Cloud
166167project:
167168
168169``` bash
169- $ gcloud app deploy app.standard .yaml
170+ $ gcloud beta app deploy app.flex .yaml
170171```
0 commit comments