Receiving HTTP ERROR 500. Can't Remember What I Misconfigured

Server version: Apache/2.4.38 (Unix)

PHP Version: PHP 7.3.3 (cli) (built: Mar 6 2019 18:03:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.3, Copyright (c) 1999-2018, by Zend Technologies

OS: Linux archlinux 5.0.0-arch1-1-ARCH #1 S

Nextcloud: 15.0.5

Hello everyone. I am new to NextCloud and web in general. I am trying to set up a nextcloud web front with a domain over HTTPS. Simple… or so I thought

  • I got the web front to load. I was able to log in and everything. It worked over both the local IP and domain.

  • Next, I downloaded a certificate from LetsEncrypt. Everything appeared to go smoothly but my connection was still unsecured HTTP

  • I forwarded port 443 on my router already

  • I don’t know what I did after that. I messed around with a ton of config files by changing ServerNames, VirtualHosts and all sorts of stuff.

  • Now my webpage loads to HTTP ERROR 500

I have ABSOLUTELY NO CLUE what I misconfigured to get here. I don’t know enough to isolate the problem. I modified httpd.conf, config.php, and multiple .htaccess files. I may have messed with more stuff but I wouldn’t remember off the top of my head. My information is in the httpd.conf file. I will provide you with the error logs. What files should I start digging through?

/var/log/REDACTED.com.info-error_log

[Mon Mar 11 20:49:26.529013 2019] [php7:error] [pid 881] [client REDACTED:49053] PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /usr/share/webapps/nextcloud/lib/private/DB/Connection.php:64\nStack trace:\n#0 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()\n#1 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()\n#2 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()\n#3 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()\n#4 /usr/share/webapps/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)\n#5 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection in /usr/share/webapps/nextcloud/lib/private/DB/Connection.php on line 64

/etc/webapps/nextcloud/config/config.php

<?php $CONFIG = array ( 'instanceid' => 'REDACTED', 'passwordsalt' => 'REDACTED', 'secret' => 'REDACTED', 'trusted_domains' => array ( 0 => '192.168.1.2', 1 => 'REDACTED', 2 => 'REDACTED', ), 'datadirectory' => '/usr/share/webapps/nextcloud/data', 'dbtype' => 'mysql', 'version' => '15.0.5.3', 'overwrite.cli.url' => 'http://192.168.1.2', 'dbname' => 'nextcloud', 'dbhost' => 'localhost', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'daniel', 'dbpassword' => 'REDACTED', 'installed' => true, );

/var/log/httpd/error_log

AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using REDACTEDIPv6. Set the ‘ServerName’ directive globally to suppress this message
[Mon Mar 11 21:18:28.080687 2019] [mpm_prefork:notice] [pid 1049] AH00163: Apache/2.4.38 (Unix) PHP/7.3.3 configured – resuming normal operations
[Mon Mar 11 21:18:28.080742 2019] [core:notice] [pid 1049] AH00094: Command line: ‘/usr/bin/httpd -D FOREGROUND’
[Mon Mar 11 21:21:35.279365 2019] [mpm_prefork:notice] [pid 1049] AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 11 21:21:35.407886 2019] [mpm_prefork:notice] [pid 1069] AH00163: Apache/2.4.38 (Unix) PHP/7.3.3 configured – resuming normal operations
[Mon Mar 11 21:21:35.407941 2019] [core:notice] [pid 1069] AH00094: Command line: ‘/usr/bin/httpd -D FOREGROUND’
[Mon Mar 11 21:23:37.312514 2019] [mpm_prefork:notice] [pid 1069] AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 11 21:23:37.429584 2019] [mpm_prefork:notice] [pid 1086] AH00163: Apache/2.4.38 (Unix) PHP/7.3.3 configured – resuming normal operations
[Mon Mar 11 21:23:37.429635 2019] [core:notice] [pid 1086] AH00094: Command line: ‘/usr/bin/httpd -D FOREGROUND’

Solution

Reinstall Nextcloud and it’s respective dependencies.

recertified with Certbot. Take note of the private key location in the output logs.

Now we are back to where we started.

Follow the TLS installation instructions in the AUR

Modify the ssl config

sudo nano /etc/httpd/conf/extra/httpd-ssl.conf

Change ServerName, Admin and Document Root

If you want to add strict non-redirectable HTTPS (and you should), Add a line under

Header always set Strict-Transport-Security “max-age=31536000; includeSubdomains; preload”

If you chose to add strict-transport security, edit the nextcloud file

sudo nano /etc/httpd/conf/extra/nextcloud.conf

If you want to add strict non-redirectable HTTPS (and you should), Add a line under <VirtualHost *:80>

Redirect permanent / https://example.com

save and close

Restart apache

I just messed with the httpd.conf file and not it says I can’t connect to the server at all. I can not begin to express my frustration at this point. I’m just going to not touch it want wait for one of you guys to suggest a step forward.

Hi,

Your honesty is well regarded.
As you might guess already you just made a beginners error.

I´m not gonna dig in too deep in this as i doubt it is useful for neither of us.

You just won a fresh install, and this is normal while on learning.

There are are few paradigms i follow.

1.) Log what you do. I´m using putty for commandline and it has great logging features. Everything i do on the cli is dokumented that way, and i can trace every step i did.
2.) When dealing with config files or certificates and that kind, i always copy it from file.conf to file.conf.old even multiple times in different versions. Only skip this step if you are 110% confident on what you are doing.
3.) Look up how software you are dealing with works before Configuring the shit out of it.
4.) Work with VMs and take Snapshots (and know how they work).
5.) Dont put production data or live users on your system before you KNOW you are production ready.
6.) Do not make Assumtions.
7.) Configure one piece at a time. Dont mix too many things.
8.) Be Curious while learning/testing. Be cautious as darn hell when dealing with a live system.
9.) If you expect to get help, put freaking version numbers and names of the software you use EVERYWHERE.

Thank you for the reply Ascendancer. What software versions do you want? Just nextcloudd and my OS? Do you want my PHP and MariaDB versions as well? I didn’t place in versions simply because I don’t know what it relevant to this post. I decided to cut my losses and reinstall nextcloud to get all the default files back. Problem is it won’t reinstall. I have moved the discussion to the following thread and I will update this particular thread when the installation problem is resolved. I know this isn’t a priority but I see this as a profesional community. I wish your responses were less rude.

Updated both threads with versions of PHP, Apache and the OS

Solution

Reinstall Nextcloud and it’s respective dependencies.

recertified with Certbot. Take note of the private key location in the output logs.

Now we are back to where we started.

Follow the TLS installation instructions in the AUR

Modify the ssl config

sudo nano /etc/httpd/conf/extra/httpd-ssl.conf

Change ServerName, Admin and Document Root

If you want to add strict non-redirectable HTTPS (and you should), Add a line under

Header always set Strict-Transport-Security “max-age=31536000; includeSubdomains; preload”

If you chose to add strict-transport security, edit the nextcloud file

sudo nano /etc/httpd/conf/extra/nextcloud.conf

If you want to add strict non-redirectable HTTPS (and you should), Add a line under <VirtualHost *:80>

Redirect permanent / https://example.com

save and close

Restart apache

Are you using the Arch-supplied packages, and using the Arch wiki for the installation instructions? If you’re having problems with the Arch wiki, then maybe you could report the problem to the Arch wiki or on the Arch forums?

It might be a good idea to start simple, so get a PHP page working over SSL first. Then, when you’re comfortable with that, move on to installing Nextcloud (which should be pretty simple).

There was nothing wrong with the Wiki. I just wasn’t clear on how these problems occurred. Typically people need to modify .htaccess files but I forgot nextcloud.conf was basically just that. Based on my solution I can infer that the Nextcloud forums was truly the most relevant community,