diff --git a/tools/jenkins/grpc_interop_php/Dockerfile b/tools/jenkins/grpc_interop_php/Dockerfile
index 09da71369170a33d61d37e20d61c7e6e8acb4525..492d20cdb51964f08ab073baa531a55d583aef6b 100644
--- a/tools/jenkins/grpc_interop_php/Dockerfile
+++ b/tools/jenkins/grpc_interop_php/Dockerfile
@@ -100,5 +100,19 @@ RUN /bin/bash -l -c "rvm all do gem install ronn rake"
 RUN curl -sS https://getcomposer.org/installer | php
 RUN mv composer.phar /usr/local/bin/composer
 
+# Download the patched PHP protobuf so that PHP gRPC clients can be generated
+# from proto3 schemas.
+RUN git clone https://github.com/stanley-cheung/Protobuf-PHP.git /var/local/git/protobuf-php
+
+RUN /bin/bash -l -c "rvm use ruby-2.1 \
+  && cd /var/local/git/protobuf-php \
+  && rvm all do rake pear:package version=1.0 \
+  && pear install Protobuf-1.0.tgz"
+
+# As an attempt to work around #4212, try to prefetch Protobuf-PHP dependency
+# into composer cache to prevent "composer install" from cloning on each build.
+RUN git clone --mirror https://github.com/stanley-cheung/Protobuf-PHP.git \
+  /root/.composer/cache/vcs/git-github.com-stanley-cheung-Protobuf-PHP.git/
+
 # Define the default command.
 CMD ["bash"]
diff --git a/tools/jenkins/grpc_interop_php/build_interop.sh b/tools/jenkins/grpc_interop_php/build_interop.sh
index cd9d67804af685ed987362423e401be1d32a98ba..87262f1d62983d601f5c159cb504560175d6af69 100755
--- a/tools/jenkins/grpc_interop_php/build_interop.sh
+++ b/tools/jenkins/grpc_interop_php/build_interop.sh
@@ -29,7 +29,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # Builds PHP interop server and client in a base image.
-set -e
+set -ex
 
 mkdir -p /var/local/git
 git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc
@@ -45,18 +45,10 @@ make install-certs
 # gRPC core and protobuf need to be installed
 make install
 
-# Download the patched PHP protobuf so that PHP gRPC clients can be generated
-# from proto3 schemas.
-git clone https://github.com/stanley-cheung/Protobuf-PHP.git /var/local/git/protobuf-php
-
 (cd src/php/ext/grpc && phpize && ./configure && make)
 
 (cd third_party/protobuf && make install)
 
-(cd /var/local/git/protobuf-php \
-  && rvm all do rake pear:package version=1.0 \
-  && pear install Protobuf-1.0.tgz)
-
 (cd src/php && composer install)
 
 (cd src/php && protoc-gen-php -i tests/interop/ -o tests/interop/ tests/interop/test.proto)