Getting e-mail happening

So I had this brainwave and thought it’d be a good idea to set up a Pi as an e-mail server. After all, how hard could it be, there are hundreds of thousands of mail servers around the globe that work well. What could possibly go wrong ?

I started out trying to keep it simple. I’m pretty familiar with Sendmail but I figured that I’d go with something simple as I was only going to serve two users and Sendmail seemed a lot of overkill.

After a bit of searching Citadel seemed to fit well. I installed it and configured but there is no way I could get past a couple of errors not the least if which is “db:cursor still in progress on cdb 02: attempt to write during a r/o cursor”. I tried a completely fresh install of Raspbian Buster with a brand new install of Citadel. Still no dice. Searched for more comprehensive doco but, again, to no avail. I reckon I just about wore out the search engines looking for a solution but still no illumination. I even tried downloading the source and buildin it from scratch. The same olf “db:cursor still in progress…” error persisted.

Scratch Citadel which is a pity really as I reckon it’d be the bees knees for a simple and small e-mail server.

On to Dovecot and Postfix. I had a few issues but by carefully following the documentation on Postfix.org I had it all up and running. In the beginning I had a lot of trouble getting “saslauthd” to do the authentication and I spent a goodish amount of time trying to treat the symptoms without success. At this point I decided to get rid of postfix and dovecot and start again from a new install of both. The big difference this time was that I folloed the docs on postfix.org to the letter. Surprise, surprise it all worked as it should.

After years and years of telling people to RTFM I didn’t.Once I did RTFM I proved my own point yet again.

Now came the hard part. DNS records. I use a dynamic DNS which has served me very well thus far. Setting up the MX record was very easy but I discovered I needed a PTR (for reverse lookups) and this is where the gremlins started to creep in. I needed a static address. No problem just ask my ISP, right ? Easily doable, for another ten bucks a month. Sign the static IP over to the dynamic DNS provider so that they can use it for all DNS records. ISP says – “oh no we can’t do that”. Luckily my dynamic DNS provider has a facility that can easily get around that particular scenario.

Now that it all works, I’m happy and am quite willing to advocate for the Postfix / Dovecot sulution. It’s a lot easier to configure than Sendmail. The configuration files are well commented and make sense, unlike Sendmail.

If you’re considering setting up your own mail server first check that you can get a PTR DNS record. If you can’t look for another solution. If you can, RTFM and pay attention to the details and recommendations.

Just for fun and games on our internal network I set up a DNS complete with MX and PTR records and with the internal e-mail system configured to insist on reverse lookups it worked perfectly with no errors. Of course this was only with two Pi’s, two PC’s and two windows tablets. I’ve got rid of it all now I know how to make it work and that there’s no point with an uncooperative ISP.

What to do with a second Pi

As the title asks – what to do with a second Pi ? I “accidentally” ended up with a Raspberry Pi 4 1GB to partner my 4GB unit so what to do with it.

The original Pi has LAMP installed and running well. It’s also got 1TB of storage for all my videos and photo’s and stuff and we use it to watch movie’s and TV series using our lounge room TV as the monitor. It works really, really well so I’m quite reluctant to change anything. It does need a fan heatsink though, to keep the temperatures under control. With the fan it only gets up to 55deg C max.

I have a USB DVB-T/2 dongle as well as a Pi TV hat. The TV hat doesn’t fit on my 4GB Pi because I have a fan case on it and a couple of the GPIO pins are used to power the fan. The TV Dongle was pressed into service and works OK with TV Headend. It’s not as sensitive as the Pi Hat despite using the same chipset so I pressed an RF amplifier into service in the antenna cable and it works a treat.

So. In the lounge room, behind the TV I have the 4GB Pi with a TV dongle and a 1TB SSD  with all my stuff attached. In the bedroom, where there’s no antenna socket, I have a smaller TV and a Pi 1GB. The Pi, using VLC, can play the TV from the lounge room Pi running TV Headend and using Samba can also play, using VLC again, all of our shows and movies.

Given that we’ve got good WiFi 5GHz coverage throughout the house thanks to a couple of WiFi extenders, for our grandson and visitors all I need to do to give them HD TV and shows and movies is to move the Pi and give them a keyboard. Our grandson can watch his Youtube stuff to his hearts content without annoying us.

Seeing as how successful that is I reckon another Pi to use for the same purpose in the BBQ area out the back could be the go. Watching the cricket while we’re having a BBQ and a few beers sounds pretty appealing to me. Setup is easy – Latest Raspbian with VLC, power supply and HDMI cable. Seems a bit of a waste of a Pi 4 though. I’ll have to have a look at the specs and get a few opinions of the capabilities of “lesser” and cheaper Pi’s and maybe get a couple more.

Moving the root partition.

This a summary of an article describing how to move the root partition found on the Raspberry Pi Forums .

Before you do anything do a “lsusb”without your external storage plugged in. Then plug in your external storage and do a “lsusb” again to make sure that your storage is going to work OK.

Before you start give a bit of thought as to how you want your storage partitioned. I just left my SSD as a single 500GB partition. In the future I can see that I’ll be adding more to house my collection of music and videos.

Anyway, without further ado, if you follow this guide  to the letter I’m quite sure you’ll have no problems.

LAMP + WordPress

This is not intended to be a complete HOWTO for Linux (Raspbian), Apache2, PHP, MySQL and  WordPress on a Raspberry Pi 4 4GB. What it is supposed to be is a guide that demonstrates that it is easy to get LAMP + WordPress going on a Pi with some links to the documentation that I used.

Assuming you’ve got your Pi and possibly some external storage it’s important to plan out what you’re trying to accomplish and how you want to go about it.

So, I had a 4GB Pi4 as well as a Sandisk Extreme external SSD. First step was to get the latest Raspbian (Buster) in an SD card and booting. Once that was accomplished I installed Apache2 and got that working properly. MySQL / MariaDB was the next cab off the rank followed by PHP and php-mysql.

After each step it’s a damn good idea to make good and sure that what you’ve just installed works properly.

Downloading and installing WordPress was quite possibly the easiest part of the whole process.

For each of the LAMP components there is a heap of available documentation available – remember that Google is your friend. The Raspberry Pi Forums are a brilliant resource. The MariaDB documentation is comprehensive to say the least as is the PHP documentation. There is more WordPress documentation than any mortal could ever want.

So, the steps I followed were :-

  1. Get Raspbian working.
  2. Download, install and get Apache2 working.
  3. If you are going to get SSL working this is when you’d do. I decided not to and just skipped it.
  4. Download and get MariaDB installed and working.
  5. Get PHP and php-mysql downloaded, installed and working.
  6. Get the latest version of WordPress downloaded and installed.
  7. In MySQL reate the WordPress user and the WordPress database.
  8. Set up the privileges for the user.
  9. Configuring WordPress is pretty trivial IF you follow the WordPress procedures.

This is a much more complete HOWTO.

Once I got it all working I set about getting all my stuff over from an ISP’s server. Lots of copying and pasting is all it took.

Once I got it all over I started messing around with WordPress themes and layouts. The choices are bewildering and the theme and layout of this site is a “first attempt mess” which I’ll refine as I work out what I want and how to get there.

At this point I decided that a 32GB SD card probably wouldn’t be enough so I decided to press a Sandisk Extreme 500GB SSD into service. I found a great HOWTO on the  Raspberry Pi Forums and it worked first time. I’ll put that procedure into another post.

Getting rid of the heat

So when I use the Pi to watch movies on our TV it tends to get a bit hot under the collar – up to around 81 or 83degC. Something needed to be done about that state of affairs so I installed it in a heatsink case with fans.

Pi with heatsink case with fans.

Much better. No matter what I do I can’t get the temperature over 55degC.

While I was at it I decided to go with the 64 bit kernel so I added arm_64bit=1 to config.txt so now uname -a gives me :-

Linux markpi 4.19.75-v8+ #1270 SMP PREEMPT Tue Sep 24 18:59:17 BST 2019 aarch64 GNU/Linux

Everything still works as it should – Apache2, PHP, MySQL and VLC which we use a lot for movies, tv series, etc.

The next step is a TV HAT or a TV USB dongle – probably the dongle as that won’t mean messing around with GPIO standoffs, etc to get it to fit with the heatsink.