Skip to main content

Dockerize Wordpress Stacks for Easy Migration

 

Assalamualaikum, 

 


 

After using Google Cloud free credit  for 3 months, its time to migrate our Wordpress website!

I have launched https://4nutz.tk an e-commerce website that sells our own home-brand Natural Nut Butters! 

To save money, development was done on Google Cloud Compute Engine, after 3 months running, putting all the contents there! Tracking our own sales, finally its time to migrate. 

At the beginning, i don't want to put so much effort in running it up, used Bitnami image to run the Wordpress. Everything was easy and breezy!

But aware of the time limit, yes we need to migrate eventually. Because the Google Cloud pricing is too expensive for me! $20 per month? kidding me. 

Running the website on Digital Ocean is much cheaper $5 per month! Register using my referral link ya! you will get free $100 credit for 2 months! gets your hands dirty and start running you own web app / projects~

Ive been a fan of DO since the beginning, the price offer is very attractive, documentation support are extensive, dashboard is stunning, no down time experienced so far. 

 Now its time to take a step more, by dockerizing the Wordpress and its dependents stacks. As migration is really a pain to setup all the environments! Having this configurations set up life will be easier later if I again want to change platform, or move around or replicate or whatever!

for the dockerizing steps i followed this full guide.

Issue encountered:

1. Nginx 404 Permission issue on accessing Wordpress Docker container web content:

 When try to accessing the the Wordpress site, the Nginx running in the docker container unable to access the Wordpress container contents. thus i tried to map the Wordpress content to host machine path too and update the user id for www-data and update the permission for the content path!. And it works! thanks to this article

Quoted the article as below :

     $ sudo userdel www-data
$ sudo useradd -u 82 www-data

 

      $ sudo mkdir -p /data/html
      $ sudo
chown -R www-data:www-data /data/html

 

2. Error on accessing wp-admin & data not added when add to cart:

Saw the following error, 
 
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/themes/storefront-child/functions.php:
 
it happened probably due to the file copies that i did from Google Cloud to DO is corrupted or changed. I just need to edit the functions.php files and remove the extra lines and space ended in the file.
 
 
 

Restoring Wordpress & DB backups 

Previously I have shared how to create backups and restore backups for Wordpress & DB, have a look on my tutorial!
 
I restored the Wordpress files to <docker_project_folder>/data/html folder, copied over the files and force recreate on Wordpress container. 
 
For DB i copied over the SQL dump file to <docker_project_folder>/data/mysql and access the container to run the restore command. it can be done outside container too~ google hehe.
 
Notice that i linked the container volume to host paths for both Wordpress and MySQL
 

Push the changes to remote repository

This time I am going push the files to remote repository. Its time to be more systematic~ 
 
For Docker repo, the files that I am pushing over is 
 
<docker_project_folder>/docker-compose.yml
<docker_project_folder>/nginx-conf/*
 
For Wordpress repo, there will be two repo, themes and plugins, as i havent write any custom plugin yet, i will be only focusing on theme repo
 
Pushing the changes of custom theme to remote repo~
 
 
OK that's all for these 2-3days exploring, improving, maintenance job!
 

Comments

Popular posts from this blog

Tutorial on Min3D framework using Android Studio

Salam peeps, UPDATES***, the model on the old link is no longer working. so i have create a github repo, where i put the source code in a project, you guys can try to clone in and run on your android studio device emulator or directly on your phone, Ive replaced the model with a cube. https://github.com/aliaramli/Min3DTutorial Previously i ve posted tutorial on min3D using eclipse IDE, i believe most of us has moved to Android Studio IDE in developing android apps? As previous tutorial shows a lot of support from readers and among hot post in my blog, i ve decided to post the same tutorial but this time using Android Studio. For those who are familiar with Eclipse/Android Studio migration they might not have problem in running this tutorial . For more detail explanation on min3D please visit this website page Ok lets get started. Step One Create a new android project in android studio. you may name it as what you like, below are how i defined my project settings. ...

Get the last active time from users in woocommerce using sql query

To easily get the last active time from users (under Woocommerce extended plugin) we can easily query from database using the meta_key of "wc_last_active" example query: select user_id, meta_value from wp_usermeta where meta_key= "wc_last_active" and user_id in (11111,112222); results: +-------------+------------------+ | user_id    | meta_value | +-------------+-------------------+ |   11111   | 1556755200 | |   112222 | 1566518400 |

AWS Workspace Device is not Authorized Linux Client

Have you guys tried the AWS Workspace? They are offering the service for free from April - June 2020. For a limited time, in response to COVID-19 , starting April 1, 2020 through June 30, 2020, Amazon WorkSpaces Free Tier provides up to 50 WorkSpaces with Windows Standard bundle with 80 GB Root and 50 GB User Volumes, running in AutoStop mode for up to 10,000 hours of combined use per month across all AWS Regions where WorkSpaces Free Tier is currently available. Additionally, the Amazon WorkSpaces Free Tier provides one WorkSpace with Windows Performance bundle with 80 GB Root and 100 GB User Volumes, running in AutoStop mode for up to 200 hours, two WorkSpaces with Linux Standard bundle with 80 GB Root and 50 GB User Volumes, running in AutoStop mode for up to 400 hours, and one WorkSpace with Windows Value bundle with 80 GB Root and 10 GB User Volume, running in AutoStop mode for up to 200 hours. All new customers that start using WorkSpaces for the first time during ...