Build WordPress Blog on GCP

Build WordPress Blog on GCP

Juby

Deploy WordPress using bitnami

There are two popular methods to install WordPress on Google Cloud Platform: WordPress certified by bitnami or Google click to deploy. The former one has a cheaper plan that costs about $5 every month, so I choose it. The installation process is so easy that just takes on click. After installing, it generates username and password for you by default. The WordPress username is user, and the usernames of MySQL and phpMyAdmin are root. Their passwords are the same that you can find in VM instance. Change blog domain name

The bitnami version WordPress is a little annoying that you can’t change the website url in the dashboard. The correct method is as below:

Go to VM instances, connect SSH and open in browser window.

Find and Open wp-options.php file using command:

sudo -i
vim /opt/bitnami/apps/wordpress/htdocs/wp-config.php

Replace this two line

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');

with

define('WP_SITEURL', 'http://' . 'your_domain_name' . '/');
define('WP_HOME', 'http://' . 'your_domain_name' . '/');

Change admin user email

This problem seems to exist for a long time that if you change admin user’s email, you will be reminded that “There is a pending change of your email”, but you receive no verification email. You can change the email address in general setting by go to the URL http://your_website_url/wp-admin/options.php, but it still not work for admin user’s profile. One way is to connect to the database and go to usermeta table and delete _new_email entry and then go to user table and manually edit the user’s email address by using phpMyAdmin.

So how to connect to phpMyAdmin? Take Mac as an example.

First, you should generate a SSH key in the Terminal:

ssh-keygen -t rsa -C username

The key file is saved to ~/.ssh by default and contains two file named id_rsa and id_rsa.pub.

Second, copy the id_rsa.pub by

pbcopy ~/.ssh/id_rsa.pub

and paste it to a text editor.

Then you need to copy the key to the VM instance: click the instace name to see details -> choose edit option -> add SSH key -> change key’s usename to bitnami.

Then execute such command chmod 400 ~/.ssh/id_rsa, and connect to phpMyAdmin:

ssh -N -L 8888:127.0.0.1:80 -i ~/.ssh/id_rsa bitnami@your_server_ip

Finally, open the link http://127.0.0.1:8888/phpmyadmin in the browser.

For more information and guides, you can go to the documents of GCP and bitnami.

Highlight code block

There is an awesome plugin that can help you highlight code block in Gutenberg editor, this is the author’s post: code-syntax-block.