Read about OpenEMR's Response to the COVID-19 Pandemic at https://www.open-emr.org/covid19/

POST 500 error (blank page) when setting up TOTP MFA

Situation
I am having this issue on an AWS instance (I’m not sure if this is file permissions screwing this). So what happens is, I go to MFA configuration, select TOTP -> enters the password and blank page (screenshot attached).

any suggestions on where to start looking into?
OpenEMR Version
5.0.2
Browser:
Chrome

Logs
Chrome debugger shows 500 POST error on mfa_totp.php and error is pasted below;

        function e(t, e) {
            return "function" != typeof t || t.replaced ? t : (e.replaced = !0,
            e)
        }
        var n, r, o, u = 0;
        if ("undefined" != typeof CustomEvent && "function" == typeof window.dispatchEvent) {
            function s(t) {
                try {
                    if ("object" == typeof t && (t = JSON.stringify(t)),
                    "string" == typeof t)
                        return window.dispatchEvent(new CustomEvent("lprequeststart",{
                            detail: {
                                data: t,
                                requestID: ++u
                            }
                        })),
                        u
                } catch (t) {}
            }
            function c(t) {
                try {
                    window.dispatchEvent(new CustomEvent("lprequestend",{
                        detail: t
                    }))
                } catch (t) {}
            }
            "undefined" != typeof XMLHttpRequest && XMLHttpRequest.prototype && XMLHttpRequest.prototype.send && (XMLHttpRequest.prototype.send = e(XMLHttpRequest.prototype.send, (o = XMLHttpRequest.prototype.send,
            function(t) {
                var e = this
                  , n = s(t);
                return n && e.addEventListener("loadend", function() {
                    c({
                        requestID: n,
                        statusCode: e.status
                    })
                }),
                o.apply(e, arguments)
            }
            ))),
            "function" == typeof fetch && (fetch = e(fetch, (r = fetch,
            function(t, e) {
                var n = s(e)
                  , o = r.apply(this, arguments);
                if (n) {
                    function u(t) {
                        c({
                            requestID: n,
                            statusCode: t && t.status
                        })
                    }
                    o.then(u).catch(u)
                }
                return o
            }
            )));
            function i(t) {
                return e(t, function() {
                    try {
                        this.dispatchEvent(new CustomEvent("lpsubmit"))
                    } catch (t) {}
                    return t.apply(this, arguments)
                })
            }
            function t() {
                if (document && document.forms && 0 < document.forms.length)
                    for (var t = 0; t < document.forms.length; ++t)
                        document.forms[t].submit = i(document.forms[t].submit)
            }
            document && "interactive" === document.readyState || "complete" === document.readyState ? t() : window.addEventListener("DOMContentLoaded", t, !0),
            Document.prototype.createElement = e(Document.prototype.createElement, (n = Document.prototype.createElement,
            function() {
                var t = n.apply(this, arguments);
                return t && "FORM" === t.nodeName && t.submit && (t.submit = i(t.submit)),
                t
            }
            ))
        }
    }();

Apache error log

mod_fcgid: stderr: #4 /home/website/public_html/library/classes/Totp.class.php(68): ParagonIE\\MultiFactor\\Vendor\\GoogleAuth->makeQRCode(Object(BaconQrCode\\Writer), '/tmp/oerftuFOF', 'admin', in /home/website/public_html/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Png.php on line 42, referer: https://domain.com/interface/usergroup/mfa_totp.php?action=reg1

I fixed this issue, it was a problem of not installing the php-gd library. Installed it and then enabled it by uncommenting it on the php.ini.