Tag Archives: linux

Pelican Blog Workflow and Blogger Migration Tips

I migrated away from Blogger this month to using Pelican Static Site Generator. It’s very different, and the change is quite a bit to get used to. Previously, I’d log into blogger and draft away, add some images and publish.

Now I store my raw markdown blog posts in a Bittorrent sync folder that syncs between my desktop, mobile devices, and netbook. From here, I connect to my webserver using SSH and upload the post and all related media. I then run the pelican command which outputs the static site to the webservers htdocs/www folder.

Pros? Absolutely no server side scripting on the server. No PHP, no CGI, and of course there is no MySQL server anywhere in sight. It’s brilliant. This also means I sidestep any problems such as the xmlrpc.php issues that seem to be plauging WordPress admins everywhere. Pages also load really damn quickly.

Cons? It’s not as simple! That’s pretty much the only draw back I can find! This is not a blogging engine for your mother. Someone has made a tutorial for posting and managing their Pelican install via Dropbox. I don’t use Dropbox myself, but I imagine it would be easy to adapt to Bittorrent Sync when I’m bored one day.

Being consistant with images is another potential snag. Due to my permalink structure (more on that in a minute!) I store my image media in a top level folder called ‘images’ therefore I can reference images using ‘/images/img_name.png’ from any post and have them work. If you didn’t do it this way, I imagine it’d just be a nightmare keeping track of post media. If you have questions, feel free to leave a comment below.

Blogger Migration Tip

When moving away from Blogger it’s a good idea to keep your permalinks the same as they were to avoid losing out on search engine hits. To achieve this with Pelican, add the following to your pelicanconf.py file:

ARTICLE_URL = "{date:%Y}/{date:%m}/{slug}.html"
ARTICLE_SAVE_AS = "{date:%Y}/{date:%m}/{slug}.html"

Also, add the following to make yearly and monthly archive pages work:

YEAR_ARCHIVE_SAVE_AS = '{date:%Y}/index.html'
MONTH_ARCHIVE_SAVE_AS = '{date:%Y}/{date:%m}/index.html'

This will result in blog post URLs that match the Blogger’s default URLs. Just make sure when you move everything over that you keep the ‘slug’ the same as what was stored with Blogger otherwise the resulting URLS won’t match.

As for migrating, I did it all manually. I loaded each post up on blogger, used wget to download the images into the [pelican folder]/content/images folder, and then converted each post into Markdown. There is an RSS feed importer but I couldn’t find a way to get my older posts importer so I gave up using the importer and spend several weeks moving my posts over to markdown files for Pelican.


AWStats Alternative: GoAccess

I didn’t really want to bother with installing AWStats and setting up the cgi stuff that goes with it, as well as setting the web server to ensure the stats stay hidden. I just want to get a rough idea of who’s visiting my site and when. I’m usually happy with running a terminal window with tail -f, but sometimes a bit more analysis is needed.

Today I found a cool alternative, GoAccess.

GoAccess Main Screen

It has a nice simple and usable interface based on Curses (It’ll be familiar if you used Irssi, Mutt, or the like) and gives all the needed information at a glance. It can even output HTML reports if you really want them.

I tried installing the version from the Debian repositories but found (as usual) that it was terribly out of date. I think they had a package for version 0.5, when 0.7.1 is the latest.

If you simply head off to GoAccess’s webpage, and follow the instructions for compiling from source you’ll be up and running in no time at all. Just a note that I had issues downloading and compiling from the Sourceforge download; the resulting program would just crash and segfault. This went away when I checked out the development github code and compiled that way.

If you have issues with dependencies, try installing the following packages which should cover most of the dependencies in one command.

sudo apt-get install dh-autoreconf build-essential libglib2.0-dev libncurses5-dev libncursesw5-dev libgeoip-dev

If you’re using Lighttpd like me, when you first run GoAccess make sure to select the NCSA Combined Log Format otherwise you’ll be missing portions of your data.

GoAccess Log Confirguration Settings

Using a Linux computer in University halls

If you run Linux on a PC or laptop in halls of residence you may of realised that most universities are using 802.1x authentication on their networks. It’s great, secure all that. It can just be a pain to set up. I’m currently in halls at Bangor University and couldn’t figure out how to get it all working in Ubuntu or Crunchbang. To be fair, it’s pretty unreliable in Windows too… “Unable to authenticate!”… Grr but I digress.

I found this guide on Aberystwyth University’s website, and it worked great. Basically you need to download and make sure that wpa_supplicant is installed (It should be in pretty much all modern Linux distros), then create a config file for it using the details on the page linked. I’ll paste them below in case they ever take the page down.

Start up a command line interface and create a directory by typing:

mkdir /var/run/wpa_supplicant

Using a text editor create a wpa_supplicant.conf file in /etc/wpa_supplicant. Inside this file enter the following lines:
# BEGIN wired network configuration



      identity="your University email address" 
      password="your University password" 

# ENG wired network configuration

Open a command terminal window and type:
sudo chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf

Edit /etc/network/interfaces with the following. (The bits in bold)

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
wpa-driver wired
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf


Restart your network card by typing
sudo /etc/init.d/networking restart

You should now be connected to the University network

You’ll have to do a bit of experimenting with the identity field. Aber wants your entire uni email whereas at Bangor I just needed my username for it to work. Try both until it works. I’m fairly certain these settings are going to be fairly universal for all uni’s who utilise 802.1x authentication systems.

Thinking about the switch to Linux… (Again)

I’ve used various operating systems over the last ten years… Windows XP, Vista, 7 and 8. Apple’s OS X. Linux distributions like Ubuntu (I found some old 4.10 install discs a few months back), Debian, and more recently Crunchbang. My primary operating system currently is Windows 8 (although I was perfectly happy with 7 I just like shiny toys.)

Windows 8 gets a bad rap. Personally I think it’s undeserved as everything new and different is disliked initially. Sure losing the start menu is pretty damn drastic, but you don’t even need to ever see the start ‘screen’ ever if you don’t want to. Press Win+D and you’re back at your old desktop. Install a start menu replacement and be happy about all the new stuff in Windows 8 that actually matters. The inbuilt virtualisation stuff is cool, likewise the faster boot ups and (subjectively) snappier interface.

What currently ties me to Windows is Microsoft Office. It’s tied me for a long time. Last year for my final year HND project I got to watch one of the guys struggle with OpenOffice (now LibreOffice) trying to complete his 5000 word report. All sorts of things were just more difficult than they needed to be. Personally being used to Office is a really strong tie. If there was a way to run 100% native 100% compatible Microsoft Office I’d be running Linux as my primary OS in a flash. Maybe I’d still need to reboot for games that don’t run but that’s secondary and not as much of a concern. Rebooting to use office is a pain; rebooting for games… well if the majority of my games are separated that might do wonders for my productivity.

==Getting things to work in Linux==

Saying that I removed Ubuntu from my PC this week, fiddled around with Grub (nearly managed to hose my Windows install thankfully I got it booting again), and reinstalled the last version of Crunchbang in it’s place. The experience was a good one.

Whilst some of this isn’t specific to Crunchbang, I still think it’s good to let people know that Linux is becoming much more viable as a computing platform for the majority as time goes on. I booted up; my graphics drivers work (as in my native resolution 1920×1200 is functional) out of the box. My ethernet card is detected and although that needed manual config so does Windows or Mac due to my uni using 802.1x authentication.

Once I had my network working, Crunchbang offered to update everything for me and install various packages such as java, Libre Office, and a few others that I can’t remember. There was a bit of a fuss when installing the latest AMD graphics drivers which is made easier using a script called SMXI. It worked brilliantly until I had to reboot to unload the old un-needed kernel modules. From here, you’re supposed to run ‘sgfxi’ at a root prompt to allow the installation of the drivers to continue.

This is great except wpa_supplicant or something else important in my network configuration hadn’t been loaded. The trick is to call ‘sgfxi -W’ which skips the internet check as everything should of already been downloaded anyway. Worked great from there on and now I had the latest graphics drivers ready to go. If you get stuck after the reboot because your internet connection hasn’t connected give the above command a shot!

On the next boot I had a play with my external USB drives and was really surprised and pleased to see that whilst they are formatted as NTFS I could read them just fine. Playback in VLC worked as expected but this is the sort of thing that has changed so much since my earliest forays into Linux nearly ten years ago. Nothing worked back then. It was fun, though! Youtube worked fine, my sound card was working fine. Pretty much everything was working with minimal tinkering and configuration.

I still haven’t managed to get my printer to work (Samsung ML-2160) but that’s more likely to be a matter of persistence rather than it not actually working at all. The right driver is just waiting to be found! My next task is to replicate the ethernet sharing that I currently use with Connectify in Windows. I’ve read that dnsmasq should be able to do what I want (Bridge eth0 to eth0; provide DHCP on eth0 which is plugged into a minuture wifi access point providing wifi access to my consoles, tablet, kindle etc.)

Other than that, reinstalling Crunchbang for the first time in about three years was really good. I even got the NMR software that we use in chemistry to run (albeit I had to fiddle with the package as it was i386 rather than amd64, but I got that running in the end. Just need to send off for my licence if I decide to go full time Linux)

I am looking for a nice alternative to ChemBioDraw but I see that ACD/Labs have an older version of Chemsketch available for free that works with Wine so I’ll need to look into that. As long as it draws molecules it’ll do. Don’t need anything much more fancy than that. I also noticed that with all the Humble Bundles that I’ve been buying I have a load of native linux games to test. Yet another thing to take up my time! Of course, OpenTTD runs brilliant on Linux 😉

Linux is definitely looking more and more viable as a platform for me personally. If you don’t have the hangups of hanging on to Microsoft Office like I do; and you need no other platform specific programs then take a look at it. You might be surprised at how well it runs!

Crunchbang Linux

I’ve made space on my PC this week for Linux, in particular Crunchbang. I still dual boot into Windows for games, and currently for Skype as it doesn’t seem to like my microphone very much. Other than that, everything set itself up with minimal fuss. The installer asked if I wanted OpenOffice, and Dropbox took a minor bit of configuration to get going but seems to be pretty stable. Popoplug took a little more configuration but not more than about five minutes and now it starts itself automatically on login.

My PC is so much faster at the things I usually do; browse the web in Chrome. It’s much more secure too, which is a nice feeling. It’s much less cluttered too. If you use windows, and all you do is browsing and maybe office, definately consider switching to Linux; either Crunchbang or something slightly more mainstream such as Ubuntu!