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.

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!

WordPress Permalink formats

Having just moved my WordPress blog to OpenShift, it’s amazing how many settings apparently I had tweaked and customized on my previous site. I just followed a Google search link to one of my own posts and got a 404, and realized that the link format to my posts had changed.

I used to have links like /year/month/day/postname and now only URLs that looked like ?p=number. The first format is one of the Permalink formats. You can customize this in Settings/Permalinks. More info here.

Another server drive failure – so migrated my WordPress blog to OpenShift

So it happened. Again. Although the last time was at least 5 years ago. A ton of i/o errors in syslog, and one of my drives in a RAID1 array is not responding. Strangely the other drive although still working is reporting in SMART that it is also about to die. That seems unlikely to have two drives go at the same time?

SMART overall-health self-assessment test result: FAILED!
Drive failure expected in less than 24 hours. SAVE ALL DATA.

Uh-oh.

So here’s the deal. The last time, roughly 5 years ago, I had a drive completely die and my Ubuntu server than I run from home wouldn’t boot. I lost several months of blog posts and notes. When I rebuilt it, I installed a pair of 250GB Hitachi Deskstar P7K500 drives in RAID1 configuration. The odd thing is that one of the drives kept dropping out of the array every few months in the last year, but it could be added back with the mdadm commands so I didn’t think much of it. Maybe I should have looked more closely in the logs what was going on.

So I’m at the decision point. Probably shouldn’t just replace one of the drives if one is alreay bad, should probably replace them both. Do I want to spend a couple of hundred on another pair of drives? At least the RAID array probably saved me from completely losing everything again.

I’ve run my own Linux server from home since about 2000. It’s physically changed motherboards a couple of times, its been a PIII and most recently a P4 with just 512MB of RAM and I’ve run JBoss versions from 3.x or so upto 5.x, Glassfish 3.x, I’ve run my blog on on my own custom app (BBWeblog), then Drupal, Joomla, and most recently WordPress on Apache. I’ve enjoyed running my own server since it means I can do whatever I like with it, and other than the cost for the hardware, there’s no hosting costs for my sites.

I think it’s reached the point though where enough is enough. Time to move online somewhere. Given that I’ve been using OpenShift for a number of projects at work, it seemed an easy choice to spin up a gear using the WordPress template and just import my site. And it only took a couple of minutes to get it up and running. I spent more time playing around with the WordPress Themes than I did actually setting it up and importing my site.

The only slightly tricky part was to update the DNS entry to point to OpenShift, which involved the following steps:

  • Update my record on zoneedit.com to delete the entry for my domain. I’ve been using ZoneEdit because they support Dynamic IP addresses by giving you a script to run locally to update what your actual IP address is periodically.
  • Update my GoDaddy account to remove the ZoneEdit DNS servers, switch from Custom DNS settings to Standard, click on DNS Zone File, and then add a CNAME record for ‘www’ pointing to my apps’s URL on OpenShift
  • Back to OpenShift, run ‘rhc add-alias wordpress www.kevinhooke.com’ where wordpress is the name of my app.

This post was useful, and here’s the docs for ‘rhc add-alias’

Done! It actually only took a couple of minutes for the changes to get reflected too, i.e. if I ping www.kevinhooke.com it’s now picking up the new IP for my OpenShift server on AWS.

I’m probably still going to play around with some customization options on WordPress, but  from start to finish it was probably less than an hour. It would have taken me far much longer than that to install new drives in my server, reinstall from a drive image, and get it all set up again. So, fingers crossed, here’s looking forward to my new home on OpenShift 🙂