Internal Server error - probably caused by enabling caching

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 23.0.3
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.41
PHP version (eg, 7.4): 7.4

The issue you are facing:

I’ve been trying to get the cache working. In the process of making the necessary changes and additions, the error below appeared. Note: I had already installed apps, configured the server with email and more.

> ## 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: XXX.XXX.XXX.XXX
* Request ID: feRREaliQCI8aJYsLP3i

Is this the first time you’ve seen this error? (Y/N): Yes

Steps to replicate it:

  1. Just going to the web page for nextcloud. (there’s no option to login or do anything)

NOTE: when you examine the syslog, you will see that the system says that nextcloud is not installed and then it says it’s installed. I’m not sure why. Nextcloud was working until I attempted to add caching. I’ve been fighting with this thing for over 8 hours. Extremely frustrated … :frowning:

The output of your Nextcloud log in Admin > Logging:

I can't access the log via the web admin page - can't login.  However nextcloud log shows the following when I attempt to login: 

https://pastebin.com/nTcMJ4Rb

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

https://pastebin.com/hNMg17y7

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

https://pastebin.com/wdgcjn7b

Hi @iglo

The log says that Nextcloud cannot connect to the database. Maybe not all required PHP modules are installed? What exactley did you change? Did you uninstall / re-install any PHP modules in the process. Please post the output of php -m and dpkg --get-selections | grep -i php

Hi,

To the best of my recollection, I did not uninstall or reinstall any php modules, however looking at the output of php -m and dpkg --get-selections | grep -i php I have to wonder:

root@serv1:~# php -m and dpkg --get-selections | grep -i php
[PHP Modules]
root@serv1:~#

Ah sorry, maybe I should made that more clear…

php -m

and

dpkg --get-selections | grep -i php

…are two seperate commands.

The first one does list all compiled PHP modules. The second one should list all installed packages, that contain php in the name.

No worries. It was my fault, I should have noticed the “and” in the command instead of just copying and pasting.

Here’s the output:

root@serv1:~# php -m
[PHP Modules]
apc
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
imagick
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

root@serv1:~#

and

root@serv1:~# dpkg --get-selections | grep -i php
libapache2-mod-php                              install
libapache2-mod-php7.4                           install
php                                             install
php-apcu                                        install
php-apcu-bc                                     install
php-bcmath                                      install
php-bz2                                         install
php-common                                      install
php-curl                                        install
php-gd                                          install
php-gmp                                         install
php-igbinary                                    install
php-imagick                                     install
php-intl                                        install
php-json                                        install
php-mbstring                                    install
php-mysql                                       install
php-redis                                       install
php-xml                                         install
php-zip                                         install
php7.4                                          install
php7.4-bcmath                                   install
php7.4-bz2                                      install
php7.4-cli                                      install
php7.4-common                                   install
php7.4-curl                                     install
php7.4-gd                                       install
php7.4-gmp                                      install
php7.4-intl                                     install
php7.4-json                                     install
php7.4-mbstring                                 install
php7.4-mysql                                    install
php7.4-opcache                                  install
php7.4-readline                                 install
php7.4-xml                                      install
php7.4-zip                                      install

It seems like all the reqired PHP modules are installed, but you also have multiple PHP versions installed. Make sure Nextcloud uses the same version for CLI and Apache.

What does php -v say?

You could also try to reinstall PHP7.4:

apt remove php*

apt install libapache2-mod-php7.4 php7.4-{fpm,gd,mysql,curl,xml,zip,intl,mbstring,bz2,ldap,apcu,bcmath,gmp,imagick,igbinary,redis,smbclient,cli,common,opcache,readline,imagick,redis}

I did as you suggested and ran php-v:

php -v
PHP 7.4.3 (cli) (built: Mar  2 2022 15:36:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

I also uninstalled php and then reinstalled with the commands you provided. (Note: smbclient didn’t work - not found). After it was reinstalled, I restarted apache2.

Unfortunately, the problem remains.

I seem to remember selecting nextcloud during the ubuntu installation but never being able to access it so I manually installed nextcloud. Could that be the problem? Is the correct command to remove that “during ubuntu” installation

sudo snap remove nextcloud

?

Thanks!

How exactley? Did you use a specific guide…?

Yes. If you selected “Nextcloud” in the Ubuntu installer, it willl have installed the Snap package.
sudo snap remove nextcloud will remove / uninstall it.

I mostly used this guide: https://bayton.org/docs/nextcloud/installing-nextcloud-on-ubuntu-16-04-lts-with-redis-apcu-ssl-apache/#6-2-enable-caching

I did select “nextcloud” in the ubuntu installer but couldn’t figure out how to access it / how to use it after installation because I couldn’t find any documentation about it. Maybe I didn’t use the right keywords?

I removed the snap with sudo snap remove nextcloud. The problem remains unchanged. :frowning:

I have no data in nextcloud. Maybe I should start from scratch? If so, what’s the best, fastest and easiest way to install & configure? I’ll let you decide which is the most efficient way to handle this problem. Maybe we’re almost there?

If you have no data on it, starting over would most likely be the best option…

The Snap package or Nextcloud AIO.

If you want to be more flexible and do a manual install, I would recommand this guide:
https://www.learnlinux.tv/nextcloud-full-setup-implementation-guide/

If you want to have an even more optimimized configuartion, I can recommend Carsten Rieger’s guides (German). But his guides are defenitvly more complex, especially the one based on nginx.
https://www.c-rieger.de/

And a general advice. Make notes and document everything you do, especially when you deviate from the guide you are using and anytime when you do any changes to your setup. Maybe even write your own complete guide at some point. This will be helpful for learning purposes and for problem solving in the future.

Thank you! The learnlinux link is definitely the best guide I’ve seen. He leaves nothing out and in fact provides information that completes not only the installation but the user’s understanding of the process. I’ll definitely look at other tutorial he has.

With the help of the guide I was able to reinstall NC from scratch without deviating from the guide! Thank you very much for your help!

Before we close this ticket I was wondering if you might be able to point me in the right direction with this question:

I will be using nextcloud for my wife’s and my own personal use but I’d also like to let people involved in a charity get the benefit of some of NC’s features. Is there a way to keep the two completely separate on one NC installation or do I need to install another instance in order to do that? If it’s possible to do on one installation, is there a tutorial / guide that would explain it? I haven’t found anything in this regard.

Many thanks again for your excellent help!

Patrick

Yes, technically this should be possible. Roughly the following steps would be required to install a second instance on the same server:

  • set up another subdomain at your registrar e.g. nextcloud2.yourdomain.tld or if you want to use another main domain: nextcloud.otherdomain.tld

  • DNS for the second sub-domain or the other domain has to point to the IP of your server, just like the first one, you already setup.

  • add another database e.g nextcloud2 and maybe another database user e.g. nextcloudbuser2 to the existing MariaDB instance

  • create another directory for the second Nextcloud installation in /var/www e.g. nextcloud2.yourdomain.tld for the second Nextcloud installation.

  • Unzip the nextcloud.zipfile, you already downloaded, but this time to the newly created /var/www/nextcloud2.yourdomain.tld folder.

  • add another Apache VirtualHost e.g nextcloud2.yourdomain.tld in /etc/apache2/sites-available with the same config as the first one, except for the DocumentRoot and ServerName directives, which now should contain the details the new domain name and the path to the second Nextcloud installation in /var/www/nextcloud2

  • Enable the new Virtual Host.

  • run certbot again to get the Let’s Encrypt certificates for the second VirtualHost.