Solved Nextcloud issues.

Installed Nextcloud a while back and ran into some issues. I immediately ran into some health/family issues so I left if as it was and am now just getting back to it..
Internal Server Error
The server was unable to complete your request.
If this happens again, please send the technical details below to the server administrator.
More details can be found in the server log.
Technical details
Remote Address: 192.168.1.64
Request ID: Ip1MyqQwtuZ5Wmb4QLaZ
When I check the log file I get:
{"reqId":"WSQml18ZaPJcbi819YWl","level":3,"time":"2021-12-25T21:55:19+00:00","remoteAddr":"192.168.1.64","user":"--","app":"index","method":"GET","url":"/nextcloud/index.php/csrftoken","message":"Failed to connect to the database: An exception occurred in the driver: could not find driver","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0","version":"","exception":{"Exception":"Doctrine\\DBAL\\Exception","Message":"Failed to connect to the database: An exception occurred in the driver: could not find driver","Code":0,"Trace":[{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1486,"function":"connect","class":"OC\\DB\\Connection","type":"->"},{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1014,"function":"getWrappedConnection","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/usr/local/www/nextcloud/lib/private/DB/Connection.php","line":231,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":210,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/usr/local/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/usr/local/www/nextcloud/lib/private/AppConfig.php","line":344,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/usr/local/www/nextcloud/lib/private/AppConfig.php","line":109,"function":"loadConfigValues","class":"OC\\AppConfig","type":"->"},{"file":"/usr/local/www/nextcloud/lib/private/AppConfig.php","line":300,"function":"getApps","class":"OC\\AppConfig","type":"->"},{"file":"/usr/local/www/nextcloud/lib/private/App/AppManager.php","line":127,"function":"getValues","class":"OC\\AppConfig","type":"->"},{"file":"/usr/local/www/nextcloud/lib/private/App/AppManager.php","line":216,"function":"getInstalledAppsValues","class":"OC\\App\\AppManager","type":"->"},{"file":"/usr/local/www/nextcloud/lib/private/legacy/OC_Template.php","line":283,"function":"isEnabledForUser","class":"OC\\App\\AppManager","type":"->"},{"file":"/usr/local/www/nextcloud/index.php","line":44,"function":"printErrorPage","class":"OC_Template","type":"::"}],"File":"/usr/local/www/nextcloud/lib/private/DB/Connection.php","Line":87,"CustomMessage":"--"}}
Some info for the minds here to help:

FreeBSD Bender 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr 9 04:24:09 UTC 2021 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64



root@Bender:/usr/local/etc/mysql # pkg info | grep next
nextcloud-php80-22.2.0 Personal cloud which runs on your own server


root@Bender:/usr/local/etc/mysql # pkg info | grep mysql
mysql80-client-8.0.26 Multithreaded SQL database (client)
mysql80-server-8.0.26 Multithreaded SQL database (server)
php80-pdo_mysql-8.0.12 The pdo_mysql shared extension for php



root@Bender:/usr/local/etc/mysql # pkg info | grep apache
apache24-2.4.51 Version 2.4.x of Apache web server



root@Bender:/usr/local/etc/mysql # pkg info | grep php
mod_php80-8.0.12 PHP Scripting Language
nextcloud-php80-22.2.0 Personal cloud which runs on your own server
php80-8.0.12 PHP Scripting Language
php80-bcmath-8.0.12 The bcmath shared extension for php
php80-bz2-8.0.12 The bz2 shared extension for php
php80-ctype-8.0.12 The ctype shared extension for php
php80-curl-8.0.12 The curl shared extension for php
php80-dom-8.0.12 The dom shared extension for php
php80-exif-8.0.12 The exif shared extension for php
php80-fileinfo-8.0.12 The fileinfo shared extension for php
php80-filter-8.0.12 The filter shared extension for php
php80-gd-8.0.12 The gd shared extension for php
php80-gmp-8.0.12 The gmp shared extension for php
php80-iconv-8.0.12 The iconv shared extension for php
php80-intl-8.0.12 The intl shared extension for php
php80-ldap-8.0.12 The ldap shared extension for php
php80-mbstring-8.0.12 The mbstring shared extension for php
php80-opcache-8.0.12 The opcache shared extension for php
php80-openssl-8.0.12 The openssl shared extension for php
php80-pcntl-8.0.12 The pcntl shared extension for php
php80-pdo-8.0.12 The pdo shared extension for php
php80-pdo_mysql-8.0.12 The pdo_mysql shared extension for php
php80-pecl-APCu-5.1.20 APC User Caching
php80-posix-8.0.12 The posix shared extension for php
php80-session-8.0.12 The session shared extension for php
php80-simplexml-8.0.12 The simplexml shared extension for php
php80-xml-8.0.12 The xml shared extension for php
php80-xmlreader-8.0.12 The xmlreader shared extension for php
php80-xmlwriter-8.0.12 The xmlwriter shared extension for php
php80-xsl-8.0.12 The xsl shared extension for php
php80-zip-8.0.12 The zip shared extension for php
php80-zlib-8.0.12 The zlib shared extension for php



root@Bender:/usr/local/etc/apache24 # cat httpd.conf
#
# This is the main Apache HTTP server configuration file. It contains the
...
ServerRoot "/usr/local"
...
Listen 192.168.1.10:80
...
LoadModule mpm_prefork_module libexec/apache24/mod_mpm_prefork.so
...
LoadModule authn_file_module libexec/apache24/mod_authn_file.so
...
LoadModule authn_core_module libexec/apache24/mod_authn_core.so
LoadModule authz_host_module libexec/apache24/mod_authz_host.so
LoadModule authz_groupfile_module libexec/apache24/mod_authz_groupfile.so
LoadModule authz_user_module libexec/apache24/mod_authz_user.so
...
LoadModule authz_core_module libexec/apache24/mod_authz_core.so
...
LoadModule access_compat_module libexec/apache24/mod_access_compat.so
LoadModule auth_basic_module libexec/apache24/mod_auth_basic.so
...
LoadModule reqtimeout_module libexec/apache24/mod_reqtimeout.so
...
LoadModule filter_module libexec/apache24/mod_filter.so
...
LoadModule mime_module libexec/apache24/mod_mime.so
LoadModule log_config_module libexec/apache24/mod_log_config.so
...
LoadModule env_module libexec/apache24/mod_env.so
...
LoadModule headers_module libexec/apache24/mod_headers.so
...
LoadModule setenvif_module libexec/apache24/mod_setenvif.so
LoadModule version_module libexec/apache24/mod_version.so
...
LoadModule unixd_module libexec/apache24/mod_unixd.so
...
LoadModule status_module libexec/apache24/mod_status.so
LoadModule autoindex_module libexec/apache24/mod_autoindex.so
...
<IfModule !mpm_prefork_module>
#LoadModule cgid_module libexec/apache24/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
#LoadModule cgi_module libexec/apache24/mod_cgi.so
</IfModule>
...
LoadModule dir_module libexec/apache24/mod_dir.so
...
LoadModule alias_module libexec/apache24/mod_alias.so
...
LoadModule php_module libexec/apache24/libphp.so

# Third party modules
IncludeOptional etc/apache24/modules.d/[0-9][0-9][0-9]_*.conf

<IfModule unixd_module>
...
User www
Group www

</IfModule>

# 'Main' server configuration
...
ServerAdmin you@example.com

...
<Directory />
AllowOverride none
Require all denied
</Directory>
...
DocumentRoot "/usr/local/www/apache24/data"
<Directory "/usr/local/www/apache24/data">
...
Options Indexes FollowSymLinks

...
AllowOverride None

...
Require all granted
</Directory>

[B][COLOR=rgb(44, 130, 201)]#[/COLOR][/B]
[COLOR=rgb(44, 130, 201)][B]# Nextcloud alias
#
Alias /nextcloud /usr/local/www/nextcloud
AcceptPathInfo On
<Directory /usr/local/www/nextcloud>
AllowOverride All
Require all granted[/B][/COLOR]
[B][COLOR=rgb(44, 130, 201)] </Directory>[/COLOR][/B]

...
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

...
<Files ".ht*">
Require all denied
</Files>

...
ScriptAlias /cgi-bin/ "/usr/local/www/apache24/cgi-bin/"

</IfModule>

<IfModule cgid_module>
...
</IfModule>
...
<Directory "/usr/local/www/apache24/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>

<IfModule headers_module>
...
</IfModule>

<IfModule mime_module>
...
TypesConfig etc/apache24/mime.types
...
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
...
</IfModule>
...
<IfModule proxy_html_module>
Include etc/apache24/extra/proxy-html.conf
</IfModule>
...
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include etc/apache24/Includes/*.conf


I feel like it could be something to do with mysql, but I'm not proficient enough with it to just go rooting around in there without at least a little guidance.. But I can tell you that the DB as well as the user are installed..


root@localhost [(none)]> SELECT User FROM mysql.user;
+------------------+
| User |
+------------------+
| mysql.infoschema |
| mysql.session |
| mysql.sys |
| [B][COLOR=rgb(44, 130, 201)]nextcloud_user[/COLOR][/B] |
| root |
+------------------+
5 rows in set (0.00 sec)




root@localhost [(none)]> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| [B][COLOR=rgb(44, 130, 201)]nextcloud_db[/COLOR][/B] |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)


Any help would be greatly appreciated...
 
check nextcloud db config (verify it's set to pdo_mysql or something)
also check php -r 'phpinfo();'|grep mysql
 
check nextcloud db config (verify it's set to pdo_mysql or something)
also check php -r 'phpinfo();'|grep mysql
Not sure how to check the Nextcloud DB config. In MySql?


root@Bender:~ # php -r 'phpinfo();'|grep mysql
Configure Command => './configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--with-libxml' '--with-password-argon2=/usr/local' '--program-prefix=' '--enable-mysqlnd' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--enable-embed' '--enable-dtrace' '--prefix=/usr/local' '--localstatedir=/var' '--mandir=/usr/local/man' '--infodir=/usr/local/share/info/' '--build=amd64-portbld-freebsd13.0' 'build_alias=amd64-portbld-freebsd13.0' 'PKG_CONFIG=pkgconf' 'CFLAGS=-O2 -pipe -fstack-protector-strong -fno-strict-aliasing ' 'CPP=cpp' 'CXXFLAGS=-O2 -pipe -fstack-protector-strong -fno-strict-aliasing '
/usr/local/etc/php/ext-30-pdo_mysql.ini,
mysqlnd
mysqlnd => enabled
Version => mysqlnd 8.0.12
Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password
API Extensions => pdo_mysql
PDO drivers => mysql
pdo_mysql
Client API version => mysqlnd 8.0.12
pdo_mysql.default_socket => no value => no value

 

root@Bender:/usr/local/www/nextcloud/config # ls
.htaccess CAN_INSTALL config.documented.php config.php config.sample.php
root@Bender:/usr/local/www/nextcloud/config # cat config.php
<?php

/** This is the bare minimum configuration for the bundled installer
* to function properly.
*/

$CONFIG = array (

/** The FreeBSD package separates apps into bundled apps and user-
* installed apps. If this 'apps_paths' array is missing from
* your config, your Nextcloud installation is broken
*/
'apps_paths' =>
array (
0 =>
array (
'path' => '/usr/local/www/nextcloud/apps',
'url' => '/apps',
'writable' => true,
),
1 =>
array (
'path' => '/usr/local/www/nextcloud/apps-pkg',
'url' => '/apps-pkg',
'writable' => false,
),
),

// Log-files belong in the appropriate location
'logfile' => '/var/log/nextcloud/nextcloud.log',

// Enable user caching when option is enabled
'memcache.local' => '\OC\Memcache\APCu',
);

 
A reinstallation of those apps - MySQL, nextcloud etc. may fix it. If other database apps work fine, perhaps you can reinstall/upgrade nextcloud only. An update was push into freshports earlier this month. Your data go no where.
 
I have no clue about Nextcloud, but maybe it uses the "MySQL Improved Extension" / mysqli to perform MySQL requests (package "php80-mysqli")…
 
see https://docs.nextcloud.com/server/l...tion_server/config_sample_php_parameters.html
Code:
$CONFIG = array (
  'instanceid' => 'oc8c0fd71e03',
  'passwordsalt' => '515a13302a6b3950a9d0fdb970191a',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'studio',
    2 => '192.168.10.155'
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
   'version' => '7.0.2.1',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_carla',
  'dbpassword' => '67336bcdf7630dd80b2b81a413d07',
  'installed' => true,
);
 
Turns out mysql80 has switched over to a new authentication method that is incompatible with PHP in some way.
The corrective actions prescribed HERE is:

In MySQL 8, a new auth plugin was introduced: caching_sha2_password. That plugin does NOT work with PHP because the PHP's mysqlnd has NOT been updated. PHP 7.2.4 or higher will work with the OLD auth plugin (mysql_native_password) if you convert the mysql user account PHP connects to the db with to the old authentication! ALTER USER 'user_name'@'hostname' IDENTIFIED WITH mysql_native_password BY 'password'; In your /etc/my.cnf file you can add: default_authentication_plugin = mysql_native_password But this default only works for all new accounts created going forward.


root@Bender:/usr/local/etc/mysql # cat my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock

[mysql]
prompt = \u@\h [\d]>\_
no_auto_rehash

[mysqld]
[B]default_authentication_plugin = mysql_native_password[/B]
user = mysql
port = 3306
socket = /tmp/mysql.sock
bind-address = 127.0.0.1
basedir = /usr/local
datadir = /var/db/mysql
tmpdir = /var/db/mysql_tmpdir
slave-load-tmpdir = /var/db/mysql_tmpdir
secure-file-priv = /var/db/mysql_secure
log-bin = mysql-bin
log-output = TABLE
master-info-repository = TABLE
relay-log-info-repository = TABLE
relay-log-recovery = 1
slow-query-log = 1
server-id = 1
sync_binlog = 1
sync_relay_log = 1
binlog_cache_size = 16M
expire_logs_days = 30
default_password_lifetime = 0
enforce-gtid-consistency = 1
gtid-mode = ON
safe-user-create = 1
lower_case_table_names = 1
explicit-defaults-for-timestamp = 1
myisam-recover-options = BACKUP,FORCE
open_files_limit = 32768
table_open_cache = 16384
table_definition_cache = 8192
net_retry_count = 16384
key_buffer_size = 256M
max_allowed_packet = 64M
long_query_time = 0.5
innodb_buffer_pool_size = 1G
innodb_data_home_dir = /var/db/mysql
innodb_log_group_home_dir = /var/db/mysql
innodb_data_file_path = ibdata1:128M:autoextend
innodb_temp_data_file_path = ibtmp1:128M:autoextend
innodb_flush_method = O_DIRECT
innodb_log_file_size = 256M
innodb_log_buffer_size = 16M
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_autoinc_lock_mode = 2
skip-symbolic-links

[mysqldump]
max_allowed_packet = 256M
quote_names
quick




root@Bender:/usr/local/etc/mysql # mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost [(none)]> [B]alter user 'root'@'localhost' identified with mysql_native_password by 'XXX'[/B];
Query OK, 0 rows affected (0.00 sec)

root@localhost [(none)]>[B] flush privileges;[/B]
Query OK, 0 rows affected (0.01 sec)

root@localhost [(none)]>



I then restarted the mysql-server, and apache24 for good measure...
Page came up, and filled it out: nextcloud.png


Same Thing...
Error while trying to create admin user: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
 
It's one of the reasons some people stick with he long existing versions - mysql-server-57 & php74. You may rollback or continue hacking and prepare to effect the changes at every upgrade until those changes are pushed upstream.
 
Back
Top