Exporting WordPress content from one site and importing to a new site

WordPress has built in tools to export existing content which you can import into another WordPress site, but if you have a large site, you might run into this error when importing your exported data file:

Sorry, there has been an error.
File is empty. Please upload something more substantial. This error could also 
be caused by uploads being disabled in your php.ini or by post_max_size 
being defined as smaller than upload_max_filesize in php.ini.

There’s two parameters here that you can increase: upload_max_filesize and post_max_size. If you increase these, post_max_size should be larger than upload_max_filesize (more info here).

Next up, if you have a very large site, no matter how much you increase these params, they still might not large enough to upload a single export file. In which case, there are utilities to split the exported data xml into multiple smaller files. Here’s one example here I just and it seemed to work well.

Reducing memory usage by Apache and MySql in a 512MB VPS

Installing with the default Apache and MySQL configurations, you end up with far too many idle Apache threads, and MySQL is the largest memory user by far. The default config of these two is maxing out my available 512MB in my VPS server:

/etc/apache2$ ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r       

%MEM %CPU   RSS    VSZ COMMAND
 9.5  0.0 49904 720256 /usr/sbin/mysqld
 6.7  0.0 35620 286860 /usr/sbin/apache2 -k start
 6.5  0.0 34452 283524 /usr/sbin/apache2 -k start
 6.2  0.0 32692 283012 /usr/sbin/apache2 -k start
 5.9  0.0 31276 283116 /usr/sbin/apache2 -k start
 5.8  0.0 30896 282652 /usr/sbin/apache2 -k start
 5.0  0.0 26724 282588 /usr/sbin/apache2 -k start
 4.8  0.0 25204 279552 /usr/sbin/apache2 -k start
 4.8  0.0 25200 279552 /usr/sbin/apache2 -k start
 4.7  0.0 25156 279508 /usr/sbin/apache2 -k start
 4.4  0.0 23216 279540 /usr/sbin/apache2 -k start
 2.8  0.0 15136 278400 /usr/sbin/apache2 -k start
 0.7  0.0  3968  90908 sshd: myuser [priv] 
 0.4  0.0  2564  61312 /usr/sbin/sshd -D
 0.4  0.0  2264  33188 init
 0.3  0.0  2060  18128 -bash
...

/etc/apache2$ free
             total       used       free     shared    buffers     cached
Mem:        524288     476496      47792      68220          0     260764
-/+ buffers/cache:     215732     308556
Swap:            0          0          0

 

From tips in this article, I reduced down the Apache threads and now we’re at:

/etc/apache2/mods-enabled$ ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r
%MEM %CPU   RSS    VSZ COMMAND
 9.5  0.0 49904 720256 /usr/sbin/mysqld
 2.8  0.0 15132 278400 /usr/sbin/apache2 -k start
 1.1  0.0  6004 278424 /usr/sbin/apache2 -k start
 0.7  0.0  3968  90908 sshd: myuser [priv] 
 0.4  0.0  2564  61312 /usr/sbin/sshd -D
 0.4  0.0  2264  33188 init
 0.3  0.0  2076  18136 -bash

/etc/apache2/mods-enabled$ free
             total       used       free     shared    buffers     cached
Mem:        524288     400244     124044      68220          0     262480
-/+ buffers/cache:     137764     386524
Swap:            0          0          0

Now we’ve got some free space, and definitely not maxing out our available ram. Next up, I’ll take a look at MySQL.

Setting up WordPress on Apache and MySql on a Linux VPS host

I’ve run this blog for the past couple of years on OpenShift Online. I’ve been excited that the new Online v3 is moving to a container based service, but the cost per month is now much more than I wanted to pay. I was about to setup WordPress on AWS in an EC2 instance (if for nothing more than to get some experience playing with EC2), but after posting on Twitter for suggestions, there was a suggestion to check out cheap Virtual Private Server (VPS) offerings. The lowendbox.com site covers many offers from hosting companies offering VPS based services, so I took a look and picked up a 2 CPU core, 512MB, 200GB disk VPS for $2.50 a month. That’s a manageable cost and looks like a comparably price for a low end VPS server.

To get started after provisioning my VPS , I created a new user with sudo access instead of using the default root user created on initial setup:

  • adduser newuser
  • usermod -aG sudo newuser

On my Ubuntu 14.04 minimal server install, apparently even sudo is not yet installed, so per steps here, su’d to root, and then installed sudo:

  • su -
  • apt-get update
  • apt-get install sudo

Installed mysql-server. There’s many guides for installing MySQL, but here’s one as a reference.

  • sudo apt-get update
  • sudo apt-get install mysql-server

During installation I got this error, and the server failed to start during installation:

/var/lib/dpkg/info/mysql-server-5.5.postinst: line 150: logger: command not found
ATTENTION: An error has occured. More info is in the syslog!

From this post here, the fix is to:

  • apt-get --reinstall install bsdutils

As this ran, the mysql install started showing additional input and the server started up.

Next, setup:

  • sudo mysql_secure_installation

Followed the prompts and remove anonymous user access, test database etc.

Created a new MySQL database with user/password that WordPress will use to access the database, following steps here.

Installed apache:

sudo apt-get install apache2

Installed php modules for apache:

sudo apt-get install php5 libapache2-mod-php5

Hitting the WordPress setup url, got this error:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

This is fixed by installing the php mysql package (discussed here):

apt-get install php5-mysql

Installing WordPress from scratch is covered in detail here. The only additional step I needed to do was to tell Apache to server index.php so you’d see the WordPress site when hitting the site root url.

This can be done by editing /etc/apache2/apache2.conf and adding a DirectoryIndex:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        DirectoryIndex index.php
        Require all granted
</Directory>

Restart apache and you should be up and running:

sudo service apache2 restart

As  start this is pretty good. It looks like the default apache and mysql settings are maxing out my 512MB so I’ve got some tuning to do, and then I need to migrate my WordPress database across, but so far so good!

Building and running a Packet Radio Winlink solution in a Docker container, on a Raspberry Pi

Running Packet Radio apps in a Docker container, on a Raspberry Pi? Are you mad I hear you ask?Isn’t it hard enough to get ax25 and Packet Radio up and running on the Pi anyway? Having done this a few times already, this was my thinking, and I had the crazy idea that encapsulating most of the config and setup in Dockerfiles to build preconfigured containers might be an idea worth exploring.

Installing and configuring ax25 for the Raspberry Pi and Winlink clients that use ax25 like paclink-unix or PAT can be done and work well, but the steps, as for example documented in this comprehensive guide for building and installing paclink-unix which span several pages of instructions – this can be daunting even for those more familiar with building and installing apps from source on Linux.

Since the steps are well documented, I wondered if they could be captured in a Dockerfile to automate building a self-contained and ready to run Docker container.

tldr; The short story

I did eventually did get this working building ax25 from source and using Pat, but it took me down a rabbit hole for several hours. Skip to the end if you just want to find out how to build and run the completed Docker containers.

The Longer Explanation

I could not get ax25 to work self-contained in it’s own Docker container, as I ran into issues either accessing my serial device connected to my TNC Pi from inside the Container, and/or creating an ax0 interface when running kissattach.

If you expose the serial port on the Raspberry Pi to the Container running paclink-unix:

docker run -it --device=/dev/ttyAMA0 rpi-paclink

… When trying kissattach in the container it gives:

kissattach: Error setting line discipline: TIOCSETD: Operation not permitted

Are you sure you have enabled MKISS support in the kernel

or, if you made it a module, that the module is loaded?

Alternatively, starting with –privileged:

docker run -it --privileged  -v /dev/ttyAMA0:/dev/ttyAMA0  rpi-paclink

gives:

sudo kissattach /dev/ttyAMA0 1

kissattach: SIOCSIFMTU: No such device

I was initially trying to get this working because I wanted to run paclink-unix for Winlink email. Part of this app when you run the make script it will create wl2kserial and wl2ktelnet, but not wl2kax25. I had already run into this before, as it seems it doesn’t compile unless it has a later version of the ax25 stack compiled from source.

I changed gears and looked for how you could share an up and running ax25 stack from the Docker host, and it turns out this is easy to do, you just pass the –network=host param, and then ax0 appears in your network interfaces in your container.

The next issue I ran into is that configuring postfix as your email transport take some effort. bazaudi.com have a very detailed set of instructions, but I couldn’t get it working for outgoing email. It was working for incoming via wl2ktelnet and wl2kax25, but only for receiving emails and not sending. Time to try something else.

Installing and configuring Pat in a Container

I tried to get Pat working once before – I think I had it working on either a Debian or Ubuntu box, but couldn’t get it working on Raspbian on a Pi. I decided to try it again in this setup, and reusing the base image with ax25 already compiled from source, it was actually very easy to get Pat up and running.

This is dependent on having ax25 installed and configure on the host Pi OS, and the shared to the container with –network=host. I know, this seems redundant, but this is the only way I managed to get this working.

My base image for Raspbian including ax25 built form source is here: https://github.com/kevinhooke/DockerRPiAX25FromSource 

To build the image passing in the parameterized value for your callsign (passing your callsign in place of ‘yourcall’):

docker build --build-param MYCALL=yourcall -t rpi-ax25 .

Next build an image containing Pat, based on the image we just built – the source for this Dockerfile is here: https://github.com/kevinhooke/DockerRPiPATWinlink.git

Build this image with:

docker build --build-arg MYCALL=yourcall --build-arg MYCALLSSID=yourcall-1 
    --build-arg MYLOC=AA11aa --build-arg WINLINKPASS=yourwlpass 
    -t rpi-wl-pat .

Now to start it up remember we’re relying on an ax25 connection from the host, and we’re going to share it with the guest container. My TNC-Pi board connected to my Raspberry Pi is available on serial device as /dev/ttyAMA0, so I start up my ax0 port like:

sudo kissattach /dev/ttyAMA0 1 10.1.1.1

Next, run the container as a daemon, share the host networking, and expose port 8080 so we can access the Pat webapp:

docker run -d –network=host -p 8080:8080 rpi-wl-pat

Now let’s fire up the webapp:

Looks good, this is the Pat inbox. Let’s send a test email to myself – this is going to be sent using Packet over 2m VHF via my local Winlink gateway, AG6QO-10. I have this preconfigured in my Pat config file. You can configure this yourself before creating the rpi-wl-pat image:

Remember the Pat webapp that we’re interacting with here is running in a Docker container, on a Raspberry Pi. I just happen to be accessing it remotely from my Mac. For mobile operation or out in the field, you could attach a touchscreen to the Pi and connect a keyboard and mouse too.

To send my email over RF to the Winlink gateway, click Action, then Connect:

In the Pat status window we now see a log of the Packet exchange between my station and AG6QO-10 via BERR37:

A few seconds later the email arrives in my gmail inbox:

If I reply to the email in gmail, it will go back over the Winlink network, and be waiting for me when I connect to the Winlink gateway again over RF. Let’s give that a go in Pat – select Action and Connect, we connect to AG6QO0-10 again over 2m VHF, and now the reply is in my inbox in Pat:

Success!