Thursday, 9 March 2017

Don't halt boot if loopback mount fails

I mount the installation DVD image for my distribution with loopback mount so that I don't have to download packages if they are on the ISO image and up to date. To do this I have a line in /etc/fstab that looks like this:

/home/data/software/opensuse/openSUSE-Leap-42.2-DVD-x86_64.iso /srv/www/htdocs/42.2 iso9660 auto,ro,loop

The problem with this is that if for some reason the mount fails, say the ISO file has been renamed, or somehow the directory of the image or mountpoint are inaccessible, the boot process fails.

Enter the nofail option of systemd.mount. If the line is changed to this:

/home/data/software/opensuse/openSUSE-Leap-42.2-DVD-x86_64.iso /srv/www/htdocs/42.2 iso9660 auto,ro,loop,nofail,x-systemd.device-timeout=10

this prevents failure to mount from affecting the boot process. The problem can then be investigated after the machine has started up. The option x-systemd.device-timeout=10 specifies a shorter timeout than the default.

Thursday, 2 March 2017

Another reason for 500 Server Error from Wordpress 4.7

I tried to login to my local installation of Wordpress last night and while the home page worked, the login page resulted in a blank screen and a HTTP 500 error in error_log.

I thought it might be the move to PHP 7 by Wordpress, although I was puzzled why since it worked the last time I used it. No luck, even after upgrading my PHP packages to PHP 7, the error persisted.

So I did what I should have done in the first place, I set display_errors = On in /etc/php7/apache2/php.ini. The error was then obvious:

PHP Fatal error:  Uncaught Error: Call to undefined function gzinflate()

An install of the php7-zlib package fixed that.

I think the reason why it stopped working was that my web browsers started requesting gzip compression. That was why when I browsed the page with w3m, it worked.

There are lots of reasons why Wordpress might result in a HTTP 500 error. The takeaway lesson is that you should enable display_errors to get more clues. Remember to set it back after you have fixed the problem.