Build a Ubuntu WordPress site (migrate from Blogger)

Here is a simple tutorial on how to install WordPress on Ubuntu and migrate content from Google’s Blogger.

My wife has bugged me for a while now to migrate her blog (https://www.happyschnapper.com) from Blogger to WordPress, after all they have some cool themes, right?

I was always hesitant as I’m too much of a tight ass to pay for hosting services and didn’t want to be hassled every time my server went down at home. You’d be surprised how often IT ‘stuff’ decides to self destruct when you turn your back for only a few moments.

I bit the bullet last weekend due mostly to me being intrigued by the flexibility and simplicity of running and customising a WordPress site.

The tutorial has some quick notes I put together through my experience. I am running an Intel NUC with Ubuntu (Trusty Tahr) which happens to be a Kodi Media Centre. Luckily for me I already had in place a Synology NAS running MySQL for that setup.

Prerequisites:

  • 1 Ubuntu host with Apache installed
  • 1 MySQL (remote or local) + phpMyAdmin (cheats way)
  • 1 Blogger site to migrate

Installing WordPress

The first step is to install WordPress (assuming the pre-reqs are sorted!).

In the first instance I installed this with Ubuntu’s ‘apt-get’ function only to find it was extremely out of date. Ubuntu has a habit of not updating the WordPress source between LTS releases so its worth installing the latest from the WordPress site.

Having said that, the apt-get function is a fantastic way to install most of the pre-req components such as php5 libraries, mysql client, apache (if required) etc. So go ahead and run this after ssh’ing in to your host.

1. Install WordPress and associated components:

apt-get install wordpress
Select Yes to install all the required components.

2. You can ignore the above installed source files for WordPress (installed to /usr/share/wordpress). Download latest release from WordPress.com to your apache wwwroot folder.

cd /var/www/
wget https://www.wordpress.org/latest.tar.gz

1

3. Extract the archive.

tar xvzf latest.tar.gz

2

4. Rename the wordpress folder to your desired website.
mv wordpress/ www.happyschnapper.com

5. Find which user runs your Apache process.
ps aux | grep apache

4

6. Change ownership of the folders so that apache can get access to the files. In this instance the user running the apache daemon is ‘www-data’.
chown -R www-data:www-data www.happyschnapper.com/

7. Change the folder and file permissions to lock down access. All files should have 644 (Owner can change, all can read) and directories 775 (Owner can change, all can execute).
cd www.happyschnapper.com/
find . -type f -exec chmod 665 {} +
find . -type d -exec chmod 755 {} +

8. Copy the default config sample file and set the right permissions. In this case chmod 600 (Owner can edit, block everyone else) is set to prevent people snooping at your MySQL credentials.
cp www-config-sample.php wp-config.php
chmod 660 wp-config.php
chown -R www-data:www-data wp-config.php

 

Creating a WordPress Database with phpMyAdmin

I took the easy way out….
Well maybe not, but it does make for pretty screen shots, and created my database via the phpMyAdmin. phpMyAdmin is a GUI management interface for MySQL. If you forgo the GUI option brush up on your ‘mysql’ cli commands.

1. Load up phpMyAdmin on your MySQL box and look in with your root credentials.
10
2. Click on SQL.
11
3. Create the WordPress database (in this case I called it happyschnapper_wpdb):
CREATE DATABASE happyschnapper_wpdb;
Click Go.
12
4. MySQL will confirm the success.
13
5. Grant a user appropriate privileges. Below I am creating a user ‘happyschnapper’ and allowing login only from my Ubuntu host ‘192.168.0.5’ with password ‘HappySchn@pper!’.
GRANT ALL PRIVILEGES ON happyschnapper_wpdb.* TO "happyschnapper"@"192.168.0.5"
IDENTIFIED BY "HappySchn@pper!";

Click Go.
14
6. Flush the privileges from mysql’s memory cache so the above change is complete.
FLUSH PRIVILEGES;
15
7. You can confirm the privileges are ok by clicking More, Privileges and viewing the configuration on your WPDB.
17

Configuring WordPress to use your new DB

You can now change the default wp-config.php file and insert your database credentials and mysql database server IP. Due to its unencrypted nature it is important to have the correct ‘chmod 600’ settings applied to this file before saving.

FYI the salts and credentials are fake, so don’t try any funky business ok?….
1. Back on your WordPress host you now need to change the config file you created.
nano wp-config.php
18

2. Find the section for the MySQL settings. Enter in the accounts and database information you created earlier. In my example my database server sits on the IP ‘192.168.0.4’.
19

3. Scroll down to the authentication key and salts part of the config file. Here you need to change the ‘put your unique phrase here’ sections with your on salts. Take the easy way out and navigate to https://api.wordpress.org/secret-key/1.1/salt/ and replace the lines in your config.
21
Save your configuration file in nano by pressingCtrl-X, Y, enter.

Create website in Apache

I wont go in to too many specifics with apache, I’ll assume this is already installed and operating OK. Below are just a few basic settings to enable your website.

 

1. Modify the site-enabled apache configuration file.
nano /etc/apache2/sites-enabled/000-default.conf
22

2. Create a new virtual host (this is useful if you run multiple websites with hostheaders). The below config simply tells apache where to write logs, find the wordpress root folder and which aliases to listen on.
<VirtualHost *:80>
ServerAdmin webmaster@happyschnapper.com
ServerName www.happyschnapper.com
ServerAlias www.happyschnapper.com happyschnapper.com
DocumentRoot /var/www/www.happyschnapper.com
ErrorLog ${APACHE_LOG_DIR}/www.happyschnapper.com/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/www.happyschnapper.com/access.log combined
</VirtualHost>

23 Save your configuration file in nano by pressingCtrl-X, Y, enter.

3. Make a new log directory for your website (otherwise apache doesn’t start!).
mkdir /var/log/apache2/www.happyschnapper.com
22a

4. Restart apache (fingers crossed there were no typos!).
service apache2 restart

Configuring WordPress

We’re almost on the homestretch, time to configure your first WordPress Account and some basic info.

1. Navigate to your newly created website’s administration page, in my example http://www.happyschnapper.com/wp-admin/install.php. Follow the few pages to configure additional properties like Language, Site Titles etc.
26
2. Log in with your newly created credentials. You should see your default dashboard page.
29

Finally on to migrating Blogger!

I had a few trial and error runs with this process….

WordPress suggested the ‘Blogger Importer’ add-on to migrate the content but it didn’t work as expected with my wifes blog.
Her images imported to the WordPress Media store OK but didn’t render at all on the her posts. It may have been due to running the latest WordPress (v4.5.2) at the time along with the great big ‘Warning: This plugin has not been tested with your current version of WordPress’ visible on the plugins homepage.

Needless to say this bad boy came in handy WordPress Database Reset. A quick way to nuke your entire database and start from scratch.
Instead I opted for Blogger Importer Extended 1.3 (BIE).

1. Whilst you’re in the WordPress dashboard click Plugins, Add New. Search for ‘Blogger Importer Extended’ and install the add-on and click Activate.

2. Navigate to the Plugins, Installed Plugins page, click Start!
BIE
3. Click Ok, let’s go! (if you get an SSL error go back and try again…)
bie3
4.You will need to allow BIE access to your Blogger account. This will allow the add-on to access the content and push it to your WordPress database.
When prompted click ‘Allow’.
bie4

5.Select the blog you are migrating.
bie5
6. Ensure both ‘Convert Formatting’ and ‘Preserve slugs’ are checked. Click Continue
bie6
7. BIE will now migrate your content. This can take a while if you have a load of media content.
bie1
8. After the migration is complete you will need to assign a user as the post creator. In this example we use the account you created when configuring WordPress. Select an existing user and hit Assign Authors.
bie2

Finishing up

If all has gone to plan you should now have your Blogger content imported in to your new WordPress site.
Time to go clean up a few of the ‘demo’ posts and comments.

  • Click on Pages and remove Sample Page (this should be the newest).
  • Click on Posts and remove “Hello world!”.

I’d recommend removing BIE now that you have used it along with de-authorising its access from Blogger. This can be done via the Plugin page. Mine didn’t de-auth properly so head over to Google Blogger and remove BIE from the Authorised Apps in your settings to give it a swift kick.

Don’t forget to cut your DNS over.

 

The most arduous task will be finding a theme you like and some funky plugins.

 

Good luck!