Category Archives: Web Design

IP Addresses in WordPress

Since I was just working in a test instance of GCP, I didn’t have DNS running for the server and was using IP addresses for everything.  This posed a problem with WordPress since it stored the IP addresses from the original installation server in the configuration.  Naturally when I booted the new instance group using the disk image created from the original WordPress server, GCP assigned a new IP address to the server and the site no longer worked.

The fix is to update the database to reflect the new public IP address via ssh.  After some searching in the WordPress blogs, I was able to find the following changes which seem to have done the trick. If you don’t do this step, then whenever you access the site it will attempt to access the old IP address and fail.

chris@instance-group-wordpress-lmfd:$ sudo mysql -u root -p
password:##########
mysql> use wordpress;
mysql> show tables;
+-----------------------+
| Tables_in_wordpress |
+-----------------------+
| wp_commentmeta |
| wp_comments |
| wp_links |
| wp_options |
| wp_postmeta |
| wp_posts |
| wp_term_relationships |
| wp_term_taxonomy |
| wp_termmeta |
| wp_terms |
| wp_usermeta |
| wp_users |
+-----------------------+
mysql> UPDATE wp_options SET option_value = "http://NEW_IP_ADDRESS"
WHERE option_value = 'http://OLD_IP_ADDRESS';
mysql> exit;

I originally did this with IPv4 addresses.  However, since my goal was to get the site running with IPv6, I first changed the addresses to IPv6 via the console to test if a raw IP address would work, then I changed both addresses to the domain name, which would be the preferred option when working with a production site.  In both cases WordPress accepted the changes and the site worked as expected.  Below is a screenshot of the console with a mix of IPv6 and domain name configured.

WordPress Console

Building a Reusable WordPress Image in GCP

Installing WordPress is fairly straight forward and there are a number of Blogs which describe the process.  For my host I decided to use the standard GCP Ubuntu 18.04LTS image as the base OS.

Ubuntu Image

I then followed the Digital Ocean Blog for installing a LAMP stack and WordPress on the server.   This was fairly straight forward.  The biggest issue I had was logging back into MySQL as root to create the WordPress database.  The commands shown just say to run MySQL…’ mysql -u root -p’, but you get an authentication error when you do this without sudo first.  Dumb issue but took me a while to figure it out.

Once the host was running and WordPress was working, I then created a snapshot of the disk and from the snapshot, created an image.  An alternative is just to create the image directly from the source disk, but for that you need to shutdown the host.  I tried both methods and in this case saw no difference.  The final result is a reusable fully functional WordPress image (see this post for why it is not really fully functional)…

WordPress Image


IPv6 in GCP

I recently attended training on Google Cloud Platform to become a Google Certified Professional Cloud Architect.  During the training I learned that GCP does not support IPv6 natively on Compute Engine instances.  I have been using IPv6 at home for years and I know that Google has been supporting IPv6 on its search engine for the same amount of time, so the lack of support was disappointing. The solution for IPv6 on GCP is to implement a public facing load balancer which will expose an IPv6 address to the Internet and NAT that address to the internal RFC1918 private IPv4 address.  Although this is a valid short term option when migrating to IPv6, one of the great benefits of implementing IPv6 is to eradicate NAT from the world, so hopefully this situation is only temporary and in the future native end to end IPv6 will be supported on GCP.  In the mean time, since we need to live with this solution, I thought it would be worth while to test it and see how it works.

So that I was not just doing a basic protocol test, I decided to use WordPress as the target application.  This would allow for more robust testing of the solution and had the advantage of allowing me to practice what I had learned in training on something more than just a basic Apache server.  Another advantage is that this test would allow me to evaluate if I should move this Blog to GCP and make it IPv6 capable, since at the moment it is not.

With this in mind, I will publish a series of posts covering the steps I am following to get WordPress running on IPv6.  Not all of the steps  are directly related to IPv6, but are necessary when setting up a load balanced service in GCP.  Along the way I will share experiences and tips which might prove helpful for future installations.

In the first step, I will setup a reusable Compute Engine image with a LAMP stack and WordPress.   Using the WordPress Image I will then setup the load balancer with an IPv6 address. Finally, I will test using a native IPv6 host.  The diagram below shows an overview of the design: