Install WordPress on the Google Cloud Platform


Google has, for some weeks now, added PHP language support to its Cloud Platform. This means that you can take advantage of the Mountain View Cloud services (especially App Engine) to run applications in PHP and install the most popular and popular CMS, including WordPress.

In this article, we will see just how to install WordPress on the Google Cloud Platform (which we will call from now on GCP) using the free account that Google makes available on the App Engine and Cloud SQL platform. The basis of this article is the official documentation available on the Google Developers site and the local system used for development is Windows.

Before starting, however, two things must be specified:

  • PHP support has been activated experimentally and is restricted to access. In order to receive permission to distribute applications in PHP on the platform, you must, in addition to registering with Google App Engine, fill out the questionnaire accessible at and wait for your account to be enabled.
  • In order to create a WordPress instance on the GCP two components are needed: App Engine, the real platform for running applications, and Cloud SQL, the version of MySQL in the Cloud. App Engine is free up to 1 GB of output bandwidth, 1 GB of space and 28 hours of execution (all daily limits). Cloud SQL does not provide a free plan, but its use starts from a fairly low price: $ 0.10 per hour and $ 0.24 for 1 GB of storage per month.

Registration and creation of the application

With these premises in mind, the first thing to do is to register with GCP at At the first registration, you will be asked to indicate a name and an identifier for the first application ( Project in the language of the GCP). If you are already registered, you can register a new app by clicking on the red Create Project button on the service homepage. In both cases, the interface shown in the following figure will be presented:

Enter the application name in the Project Name field ( WordPress is ok) and in the Project ID field an application identifier, unique in the whole GCP, consisting of 6 to 30 letters, numbers or dashes. Note that the identifier, which can not be changed, will be used not only in several other points of the configuration but also in the domain to which the application will be accessible online : in our case we have created an application with ID  fc-wordpress and so we will surf our WordPress at .

The necessary software

To develop PHP applications for GCP the following software is required:

  • The 2.7 version of Python for Windows. From the download page, choose to install the latest version of branch 2.7 (in our case it was 2.7.5). Choose to install the version listed as Windows x86 MSI Installer.
  • The 5.4 version of PHP for Windows . From the PHP download page, choose the VC9 x86 Thread Safe version . PHP is distributed in ZIP format: to make it usable just extract the contents in a folder.
  • The latest available version of the App Engine SDK for PHP. In our case we have installed 1.8.3. Also the SDK is distributed in ZIP format: to make it usable just extract the contents in a folder.
  • Version 5 of MySQL for Windows. From the download page , choose the General Available version . Installing in local MySQL is not necessary to distribute the application, but it is useful to test locally WordPress before sending it to Google’s servers. During installation, leave the default settings except for the Setup Type where you have to choose Server only.

  • In the password indication window, leave the Current root password field blank . Always register the password, it will be used in the database configuration.

Our advice, also to better follow the instructions of this article, is to install the necessary software in a consistent way: create a folder in a partition of the system and, inside it, install or extract all the necessary software, obtaining a configuration similar to the one shown in the following figure. In our case, we created a folder called gae-wp in the D: partition and inside it we extracted or installed the various software.

Software configuration

Each of the software mentioned needs some small configuration that we will see below.

PHP configuration

Within the folder where you extracted PHP, rename the php.ini-development file to php.ini and add the following code block at the bottom of the file:

extension = php_curl.dll
extension = php_gd2.dll
extension = php_imap.dll
extension = php_mbstring.dll
extension = php_mysql.dll
extension = php_mysqli.dll
extension = php_openssl.dll
extension = php_pdo_mysql.dll
eextension = php_xmlrpc.dll
extension_dir = " D: \ gae-wp \ php-5.4.19-Win32-VC9-x86 \ ext "
google_app_engine.enable_functions = "php_sapi_name, gc_enabled"

The only parameter to adapt to your configuration is the path of php extensions to extension_dir s substituting to D: \ gae-wp \ php-5.4.19-Win32-VC9-x86 \ ext the full path to the PHP ext directory.

Configuring MySQL

MySQL simply needs to create a database designed to host WordPress data locally. Start the MySQL 5.6 Command Line Client program (where 5.6 varies depending on the version you have installed) by typing the name in the Windows Start menu box , enter the password indicated during installation and paste the following commands to create the database. You can of course customize the fields by replacing to gae_wp the name of the database you want to create, to gae_wp_user the username and to gae_wp_password l the password for the user.

CREATE USER ' gae_wp_user ' @ 'localhost' IDENTIFIED BY ' gae_wp_password ';
GRANT ALL PRIVILEGES ON gae_wp . * TO ' gae_wp_user ' @ 'localhost';

WordPress configuration

Now let’s move on to the WordPress configuration for GCP. First create a folder called wp-devel (or a name of your choice) in a partition on your computer. Our advice is to create it in the same main folder where you have extracted or installed the necessary software, like this:

Then download the latest available version of WordPress from, we have used version 3.6, and extract the files in a folder called wordpress inside the wp-devel folder . Still within wp-devel you need to create two files. The first must be named app.yaml and must contain the following code:

application: YOUR_PROJECT_ID
version: wp01
runtime: php
api_version: 1

- url: /(.*\.(htm$|html$|css$|js$))
  static_files: wordpress / \ 1
  upload: wordpress / (. * \. (htm $ | html $ | css $ | js $))
  application_readable: true

- url: /wp-content/(.*\.(ico$|jpg$|png$|gif$))
  static_files: wordpress / wp-content / \ 1
  upload: wordpress / wp-content / (. * \. (ico $ | jpg $ | png $ | gif $))
  application_readable: true

- url: /(.*\.(ico$|jpg$|png$|gif$))
  static_files: wordpress / \ 1
  upload: wordpress / (. * \. (ico $ | jpg $ | png $ | gif $))

- url: /wp-admin/(.+)
  script: wordpress / wp-admin / \ 1
  secure: always

- url: / wp-admin /
  script: wordpress / wp-admin / index.php
  secure: always

- url: /wp-login.php
  script: wordpress / wp-login.php
  secure: always

- url: /wp-cron.php
  script: wordpress / wp-cron.php
  login: admin

- url: /xmlrpc.php
  script: wordpress / xmlrpc.php

- url: /(.+)?/?
  script: wordpress / index.php

In red we have indicated the only parameter to be changed: instead of YOUR_PROJECT_ID you must report the identifier of the application you have created in the GCP Console (under Project ID ). If you do not remember it, just connect to the GCP console and find the ID next to the application name:

The second file to be created will be called cron.yaml and must contain the following code:

- description: wordpress cron tasks
  url: /wp-cron.php
  schedule: every 2 hours

Last but not least, copy the file php.ini changed a while ago in the same folder wp-devel ..

Ultimately, the wp-devel folder should now contain the wordpress folder, the cron.yaml and app.yaml files, and the php.ini file copied from the PHP folder.

Installing WordPress locally

At this point everything is ready to test WordPress on your computer. Start the Windows command prompt (just type cmd in the search box of the Windows Start menu ) and run the following commands:

D: \ gae-wp \ python27 \ python D: \ gae-wp \ google_appengine \ --php_executable_path = D: \ gae-wp \ php-5.4.19-Win32-VC9-x86 \ php-cgi.exe D: \ gae-wp \ wp-devel

Naturally, the indicated paths must be adapted to the configuration that was chosen and modified according to the folder in which Python, PHP was extracted and where WordPress was extracted.

If everything should be successful, simply connect to the page http: // localhost: 8080 / to view the classic configuration procedure of WordPress:

The procedure, for those who do not know it, is extremely simple. The only point to pay attention to is the database configuration. In our case, using the data we have chosen in the creation of the DB, we will have the following configuration:

At the end of the installation, we will have our own copy of WordPress running on Google App Engine:

WordPress deploy on Google App Engine

To install WordPress online on the GCP we should take two basic steps: create a database in the Cloud SQL service and deploy the application.

Configuring the SQL Cloud database

As we specified in the introduction, Cloud SQL is a service that does not include a free plan . In the basic configuration we suggest, the service will cost 10 US cents per hour for each active database plus $ 0.24 per month for 1 GB of space. “Active” means that only the time when the database is used by WordPress will be invoiced: at each access the database remains active for the next 15 minutes and then returns to the rest state (in which it generates no costs). Be careful: WordPress is configured to periodically perform tasks that require access to the DB. The time interval in our case is specified in the cron.yaml file and is set to 2 hours ( every 2 hours). To lengthen the interval just replace the number of hours you want with “2”.

Activation of Billing

Because it’s a paid service, Cloud SQL needs the billing service to be active. Connect to the GCP console , click on the application created at the beginning of this article and, from the menu viewable from the gear icon at the top right, choose the item Billing , then click on the Enable Billing button and follow the credit card registration process.

Creation of the instance

Once billing is enabled, you can now create an instance of a Cloud SQL database. Go back to the GCP console homepage , scroll through the list of services and click on Cloud SQL and then on the red New Instance button . The fields that must be completed are basically two:

  • Under Instance ID , a database identifier (for example: wordpress ) must be specified .
  • Under Applications , the identifier of the application you have created in the GCP Console (under Project ID ) must be indicated. In our case the application is fc-wordpress.

As for the other fields it should be noted that the database Region (set to United States ) must match the region set for the application (in the free version of App Engine the application can only be hosted in the United States); the Tier can be changed in case you need more RAM (increasing the expense anyway) and the Billing Plan can be changed by Per Use , where you pay according to the time of use, to Package , where you pay based on for days of use. Details on paid plans are available on a support page.

Click the blue Confirm button to create the instance .

Database creation

At this point all that remains is to create the database within the instance. At the time of writing, the GCP console does not have an instrument suitable for the purpose. To do this you must connect, with the account used so far, to the Google Console API , click on Google Cloud SQL on the left menu to find the newly created instance:

To create the database, use the command line panel provided by the service. Click on the instance name (in our case fc-wordpress: wordpress ), then on SQL Prompt at the top and paste in the text field the following lines, one by one. With each command, click Execute to execute it.

CREATE USER ' gae_wp_user ' @ 'localhost' IDENTIFIED BY ' gae_wp_password ';
GRANT ALL PRIVILEGES ON gae_wp . * TO ' gae_wp_user ' @ 'localhost';

The lines are the same that we used at the time to configure our local MySQL database and, as then, can be modified by replacing gae_wp the database name you want to create, to gae_wp_user username and gae_wp_password the password for the user. The important thing is that the data shown are the same as those used in the local copy because, at the time of deployment, WordPress configurations set locally will be replicated online.

To verify that the database was actually created, use the command to make SHOW DATABASES; sure that the database gae_wp , or how you called it, is present in the table shown as a result.

WordPress Deploy

At this point we can perform the actual deployment of the application. Open the file wp-config.php in the folder wordpress and replaced education define(‘DB_HOST’, ‘localhost’); education

if (isset ($ _ SERVER ['SERVER_SOFTWARE']) && strpos ($ _ SERVER ['SERVER_SOFTWARE'], 'Google App Engine')! == false) {
	define ('DB_HOST', ': / cloudsql / fc-wordpress: wordpress ');
} else {
	define ('DB_HOST', 'localhost');

In red we have indicated the item to be replaced: in its place must be indicated the name of your database instance that can be obtained from the GCP Cloud SQL console:

or from the Api console:

This change will allow WordPress to use the local database if it is run locally on your computer and instead use the online database when the service is deployed on Google App Engine.

That’s all. To execute WordPress deployments, if necessary modifying the indicated paths, the following command prompt statement from Windows:

D: \ gae-wp \ python27 \ python D: \ gae-wp \ google_appengine \ update D: \ gae-wp \ wp-devel

At the time of the deployment you will be asked, first, the email of your account and then the password: indicate this by confirming with a message.

To view the site you will have to point the browser to the page replacing fc-wordpress the identifier of your application. If everything has been done correctly, you will see the configuration page of your Wordress blog on Google App Engine.

The plugin to upload images and files

To make the site built with WordPress on the fully functional Google App Engine missing one last step. To upload images to the Google Cloud or manage the sending of emails or activate other CMS features, you need to create a bucket in the Google Cloud Storage service, which is a space to upload files to, and install the Google App Engine plugin for WordPress.

To create the bucket (from the cost per GB of $ 0.085 per month) you will have to access the GCP console, click on the Cloud Storage entry and then on the New Bucket button by assigning a name to the bucket. Now you need to give it read / write permissions: click on Home to go back to the Cloud Storage service start page, check the checkbox next to the newly created bucket and press the Bucket Permissions button and indicate the email address of the application in the box ( called Service Account Name ) used for the distribution of WordPress and giving the user read and write permissions (entry Owner).

The Service Account Name consists of the application identifier followed by @ in our case it will therefore be The Service Account Name can also be found in the Application Settings section of the application in the App Engine console .

Let’s move on to install the plugin locally. Launch the local version of your site by running from the Windows prompt, after possibly changing the paths, the statement:

D: \ gae-wp \ python27 \ python D: \ gae-wp \ google_appengine \ --php_executable_path = D: \ gae-wp \ php-5.4.19-Win32-VC9-x86 \ php-cgi.exe D: \ gae-wp \ wp-devel

Point your browser at http://localhost:8080/wp-admin/plugin-install.php, log in, search the Google App Engine for WordPress plugin from the search box and click on the entry Install Now . The plugin should not be activated.

Pour the local changes online by updating the online copy of WordPress on App Engine (always from the Windows prompt and always taking care to change the paths if necessary) with the command:

D: \ gae-wp \ python27 \ python D: \ gae-wp \ google_appengine \ update D: \ gae-wp \ wp-devel
The online version, at (replace fc-wordpress the identifier of your application), should show the newly added WordPress plugin: Click on Activate to activate it.

The last step is to set up the plugin: follow, from the WordPress administration, the Settings / App Engine path and in the Bucket Name box indicate the name of the bucket selected at the time of its creation. Now you are also able to upload files to WordPress, such as images or documents.

The configuration is now finished: in order to avoid unwanted billing, you can monitor consumption from the Cloud Console. To stop consumption, you will have to delete the database from the Cloud SQL service and the bucket from the Cloud Storage service.


Please enter your comment!
Please enter your name here