Nextcloud internal server error upon first login

I recently installed Nextcloud 15 as a fresh installation on my Raspberry P, however, I had some problems with it after trying to set up an SSL certificate with Let’s Encrypt. I then removed the old installation as best I could and created a new one without a problem. However, when I did the initial set-up from the web interface it hung for a while but it ultimately seemed successful. When I tried to log in using the account I had created on initial setup it returned an internal server error and directed me to an error log with the message as follows:

{"reqId":"N0SB5lrLNfWHZuLc1GfQ","level":3,"time":"2019-03-16T00:54:13+00:00","remoteAddr":"**********","user":"********","app":"PHP","method":"POST","url":"\/nextcloud\/index.php\/login?user=noahpalau&redirect_url=\/nextcloud\/index.php\/apps\/files\/","message":"openssl_pkey_export(): cannot get key from parameter 1 at \/var\/www\/html\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php#298","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/71.0.3578.98 Safari\/537.36","version":"15.0.5.3"}
{"reqId":"N0SB5lrLNfWHZuLc1GfQ","level":3,"time":"2019-03-16T00:54:13+00:00","remoteAddr":"************","user": "*********","app":"index","method":"POST","url":"\/nextcloud\/index.php\/login?user=noahpalau&redirect_url=\/nextcloud\/index.php\/apps\/files\/","message":{"Exception":"TypeError","Message":"openssl_pkey_get_details() expects parameter 1 to be resource, boolean given","Code":0,"Trace":
[{"file":"\/var\/www\/html\/nextcloud\/lib\/private\/Authentication/Token\/PublicKeyTokenProvider.php","line":301,"function":"openssl_pkey_get_details","args":[false]},{"file":"\/var\/www\/html\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php","line":70,"function":"newToken","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]},{"file":"\/var\/www\/html\/nextcloud\/lib\/private\/Authentication\/Token\/Manager.php","line":69,"function":"generateToken","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/html\/nextcloud\/lib\/private\/User\/Session.php","line":641,"function":"generateToken","class":"OC\\Authentication\\Token\\Manager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/html\/nextcloud\/core\/Controller\/LoginController.php","line":340,"function":"createSessionToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/html\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":166,"function":"tryLogin","class":"OC\\Core\\Controller\\LoginController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/html\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":99,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\LoginController"},"tryLogin"]},{"file":"\/var\/www\/html\/nextcloud\/lib\/private\/AppFramework\/App.php","line":118,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\LoginController"},"tryLogin"]},{"file":"\/var\/www\/html\/nextcloud\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\LoginController","tryLogin",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"core.login.tryLogin"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"_route":"core.login.tryLogin"}]},{"file":"\/var\/www\/html\/nextcloud\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"_route":"core.login.tryLogin"}]},{"file":"\/var\/www\/html\/nextcloud\/lib\/base.php","line":987,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/login"]},{"file":"\/var\/www\/html\/nextcloud\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/html\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php","Line":301,"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/71.0.3578.98 Safari\/537.36","version":"15.0.5.3"}

Details:

Nextcloud version: 15.0.5
Operating system and version: Raspian based on Debian 9.8 (stretch)
Apache or nginx version: Apache 2.4.25
PHP version: 7.0

The issue you are facing:

Is this the first time you’ve seen this error? Y

Steps to replicate it:
Just attempting to log in makes the server return the internal server error message

The output of your Nextcloud log in Admin > Logging:

See above

The output of your config.php file in /path/to/nextcloud

 'If you need this let me know',
  'passwordsalt' => 'If you need this let me know',
  'secret' => 'If you need this let me know',
  'trusted_domains' => 
  array (
    0 => 'IP Address',
  ),
  'datadirectory' => '/var/nextcloud/data',
  'dbtype' => 'sqlite3',
  'version' => '15.0.5.3',
  'overwrite.cli.url' => 'http://IP Address/nextcloud',
  'installed' => true,
);

The output of your Apache/nginx/system log in /var/log/____:

[Sat Mar 16 06:25:12.023156 2019] [mpm_prefork:notice] [pid 20049] AH00163: Apache/2.4.25 (Raspbian) OpenSSL/1.0.2r configured -- resuming normal operations
[Sat Mar 16 06:25:12.025226 2019] [core:notice] [pid 20049] AH00094: Command line: '/usr/sbin/apache2'
[Sat Mar 16 11:32:22.418280 2019] [:error] [pid 7217] [client 198.167.223.52:56314] script '/var/www/html/acadmin.php' not found or unable to stat

If there is anything else you need, I will try and provide it.