Use Docker-Compose To Start A Lightweight Virtual Machine Container of Locally Installed WordPress

I’m not a Docker guy because I don’t use it often. Basic commands such as “docker ps” are probably new to me, meaning I can’t easily remember them. Regardless, there are plenty of online resources for me to tap into regarding Docker, so I’m not too fretted about forgetting what command to use with Docker. Today, I found a fun Docker activity. Yep, you can already see I’m a Docker noob. Regardless, this activity is about creating a docker-compose file, then spinning up Docker to start all services that run a locally installed WordPress. This docker-compose file could be found on the Internet easily! I got a very fast Internet connection too, and so it took Docker about a minute or two, I think, to just pull the latest WordPress and MySQL 8 (or 5.7 if you want to use this version) images down to my local machine – and just a few more seconds to start the whole locally installed WordPress up.

Why is it fun to do this? Well, I’m not a PHP developer! This means I can’t just write any PHP script to take care of whatever itch I have with WordPress. WordPress is based on the PHP programming language. I am though love to code in Python, and so I thought — hmm… what if I want to Djangorize WordPress? This means, I want to export all WordPress blog posts I have on a WordPress website of mine to a Django blog web app that I will code soon – but I have way too many WordPress blog posts! The problem is I’m not also an XML guy, and so WordPress’s export file I downloaded gives me pause. Although XML’s basic rules aren’t hard – because it’s an extensive markup language – meaning tags are extensive (not restrictive like HTML) – meaning you can make up your own tags pretty much. For example, in HTML, you can only use a built-in tag such as <div></div>, but in XML you could just make up a tag like <friend></friend>. Anywho, but the XML file I downloaded from WordPress’s export (exported my WordPress blog posts) is so huge and long – one look at it I got confused. So, my original solution is to use docker to start a local WordPress up, import the export XML file from the WordPress XML file download earlier – and then just export all the blog posts to CSV. See, I can’t export WordPress blog posts directly to CSV earlier because I’m not hosting my own WordPress, but I’m using WordPress.com’s official WordPress hosting service; these guys don’t allow you to export your blog posts to any other format besides XML. Unfortunately, if I want to use local WordPress to import XML and then export to CSV file format, I have to pay for a WordPress plugin – which I don’t want to do! Regardless, it was fun to do docker-compose!

So, what now? I kick myself a bit because now I remember that Python got Pandas that can read XML files. So, I went to all the troubles with docker-compose for naught. On the plus side, I got a local backup of my current running WordPress blog. Hooray! Anyhow, I’ll use Python, Pandas, and BeautifulSoup to organize the XML blog post data to my liking in the future, and in this way, I’ll able to write a Python script that allows me to import WordPress blog posts to Django’s blog web app. For now, I’ll leave you with a fun docker-compose file that allows you to start up a docker container that contains essential running services like MySQL to let you play with a locally installed WordPress.

One more thing, you need to download Docker yourself before you can use this docker-compose file. Once downloaded and install Docker, create a new folder on a Windows machine and name it “wordpress-local”, but you can name this folder with whatever name you like. Copy and paste the docker-compose file below to a file in this “wordpress-local” folder – and save this file as “docker-compose.yml”. Open up Windows PowerShell terminal, change into the “wordpress-local” folder using commands like “cd C:\Users\your-user-name-here\wordpress-local“, make sure the “docker-compose.yml” file is in “wordpress-local” folder, and then you can do “docker-compose up -d” in the terminal. This will tell Docker to start pulling in images for the latest WordPress and whatever version MySQL you had coded in “docker-compose.yml” file, and then Docker will install these images, and start services to allow you to go to 127.0.0.1 to install WordPress locally. The volume Docker creates will be persisted, but you can do “docker-compose down --volume” in the terminal to delete all persisted Docker volumes. If you just do “docker-compose down”, then only Docker containers get deleted but not the volumes. It is fine that Docker containers get deleted because Docker is meant to be used this way – all it takes for you is to do “docker-compose up -d” to recreate and start the container again.

Docker compose file is below:

version: '2.12.2'

services:
   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     volumes:
       - wordpress_files:/var/www/html
     ports:
       - "80:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: abcdefg

   db:
     image: mysql:8
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: root-abcdefg
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: abcdefg
volumes:
    wordpress_files:
    db_data:

The line where the “docker-compose.yml” file said “version: ‘2.12.2’, you can change it to your docker-compose version. In the terminal, do “docker-compose --version” to see your current docker-compose version. The password for WORDPRESS_DB_PASSWORD and MYSQL_PASSWORD needs to be the same – because the former one is for environment settings and the latter one is the actual password that you want to set with MySQL database. You can also change the password for MYSQL_ROOT_PASSWORD to something else if you like. Oh, I almost forgot, when trying to import WordPress blog posts from the download of WordPress’s export XML file, if your file is too big, WordPress may refuse to import the blog posts. This can be fixed easily.

First, you need to install nano or vim for the Docker container. You do not need to stop the running Docker container to do this. In the terminal, do “docker ps” to see the Docker’s CONTAINER ID. In the terminal, do docker exec -it enter-the-container-id-here bash -c "apt-get update && apt-get install -y nano". Once everything is done, you can do “docker exec -it enter-the-container-id-here /bin/sh“. This allows you to mimic how you would ssh into a Linux server, but in our case, we go inside the container. Now, you can do “nano .htaccess“. Go to the very end of the file (.htaccess), and type in two lines:

php_value upload_max_filesize 256M
php_value post_max_size 256M

Save the .htaccess file. You can also create phpinfo.php file by doing “nano phpinfo.php“.

<?php
        phpinfo();
?>

Save the phpinfo.php file. Exit the container’s ssh-like environment by doing Ctrl-d on the keyboard. Now, you can go to 127.0.0.1/phpinfo.php to see if upload_max_filesize and post_max_size are actually 256 Megabytes. You can always increase the Megabytes sizes for these two php_values so WordPress can allow the importation of larger WordPress exported files. That’s it! Go ahead and import your blog posts to a local container and play around with locally installed WordPress using Docker. Have fun!

Poetry Had Got To Be Poetically Inscribed?

Just another poetry I came up with.  Hopefully, it is not that bad!

  • Poetry had got to be poetically inscribed?
  • Yes, sometimes he would like to think it!
  • No, some other time he would not so wholeheartedly have it!
  • Inscribed it might be yet it could be whatever.
  • It could be the wind blew north,
  • the sail poetically sailed the sea northward.
  • Inscribed it might be yet it could be a mood.
  • A feeling which described nothing alike.
  • Poetically, it was like one dreamy summer afternoon.
  • Around the world, colors dotted the landscapes.
  • There he was, inside a room, alone!
  • Poetically, he wrote these dreamy lines.

2012 in review

The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

19,000 people fit into the new Barclays Center to see Jay-Z perform. This blog was viewed about 150,000 times in 2012. If it were a concert at the Barclays Center, it would take about 8 sold-out performances for that many people to see it.

Click here to see the complete report.

Installing The Latest WordPress On QNAP NAS

WordPress

WordPress (Photo credit: Adriano Gasparri)

If you’re running QNAP server at home as a NAS (Network Attached Storage), you also have the option to install the latest WordPress onto QNAP. Why should you? Well, perhaps you want to clone your live WordPress blog onto your NAS for development purpose or whatever, and with QNAP NAS you can do so with ease. Nonetheless, if you install WordPress using QPKG Center within QNAP, you may only get to play with the older version of WordPress. Within this video, I will show you how to download and install WordPress onto QNAP manually. This way, you get to play with the latest WordPress version. Enjoy!!!

Smart Whatever Of The Day — You Can Be Honest On A Blog!

You can be a smart-whatever on Twitter, a faceless friend who makes many people feel awesome on Facebook, and an honest person on one’s own blog.  Of course, this is my biased, opinionated opinion on all current social trends, and so you should keep yours.  Furthermore, don’t forget to look beyond these words as there is a flip side to everything.

WordPress Encourages Millions Of WordPress Members To Make Stance Against SOPA

English: The logo of the blogging software Wor...

Image via Wikipedia

WordPress is a gigantic free blog service which allows roughly around 60 millions of people to blog freely.  According to TheNextWeb.com, WordPress has announced that it is against SOPA and PIPA.  WordPress even encourages its members to take actions against SOPA.  Perhaps, by that WordPress means its members should contact local representatives and state senators?  I don’t know much about PIPA, but I’d written extensively on how I’m against SOPA in previous blog posts of mine.  Anyhow, WordPress is truly huge, and with WordPress encourages its users to make a stance against SOPA, we can somewhat feel the movement against SOPA keeps on growing stronger.

Reddit is another popular web service which declares that they will shut down their web service for 12 hours just to protest against SOPA.  The Reddit website will go dark on January 18 from 8:00 AM to 8:00 PM.  For your information, Reddit allows people to collectively and socially discuss, submit, and vote on headlines that they feel most important to them.

Some people suggest that to make SOPA truly dead, Google and Facebook must too support Reddit by going dark and placing links on members’ profiles to encourage members to contact their local representatives and state senators to protest against SOPA.  I think these people are making sense, because Google and Facebook are so popular that the protests from these two companies might create a real backlash against SOPA, putting a stop to SOPA effectively.  Obviously, Google and Facebook might lose a lot of money by just shutting down their websites for 12 hours.

I hope more people will speak up against SOPA!  WordPress users who support to put a stop to SOPA should write blogs to inform their blog readers why SOPA is downright ugly for the Internet.  You might not know, but EssayBoard is using WordPress, and now is even more proud of WordPress since WordPress has made a stance against SOPA.  WordPress is awesome!  For your information, besides providing free blog service, WordPress also provides free blogging software which you can download and install onto your web servers freely.

Sources: