Nextcloud auf Debian 9

Cazawhi

Geht ein
Registriert
13 Feb. 2016
Beiträge
357
Ort
im Funkloch
Hallo miteinander,

Ein weiteres Problem stellt sich mir in den Weg, ein Nextcloud-System.

Ich klapperte mehrere Tutorials ab, und bis jetzt stieß ich jedes Mal auf den selben Fehler: beim Aufruf der Website <ip>/nextcloud war das Einzige, was ich zu sehen bekam, diese Ansicht: (tatsächlich so als Text, ohne Formatierung)
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author JÃķrn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Thomas MÞller <thomas.mueller@tmit.eu>
* @author Vincent Petry <pvince81@owncloud.com>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

// Show warning if a PHP version below 5.6.0 is used, this has to happen here
// because base.php will already use 5.6 syntax.
if (version_compare(PHP_VERSION, '5.6.0') === -1) {
echo 'This version of Nextcloud requires at least PHP 5.6.0<br/>';
echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.';
return;
}

try {

require_once __DIR__ . '/lib/base.php';

OC::handleRequest();

} catch(\OC\ServiceUnavailableException $ex) {
\OC::$server->getLogger()->logException($ex, array('app' => 'index'));

//show the user a detailed error page
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
OC_Template::printExceptionErrorPage($ex);
} catch (\OC\HintException $ex) {
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
OC_Template::printErrorPage($ex->getMessage(), $ex->getHint());
} catch (\OC\User\LoginException $ex) {
OC_Response::setStatus(OC_Response::STATUS_FORBIDDEN);
OC_Template::printErrorPage($ex->getMessage(), $ex->getMessage());
} catch (Exception $ex) {
\OC::$server->getLogger()->logException($ex, array('app' => 'index'));

//show the user a detailed error page
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
OC_Template::printExceptionErrorPage($ex);
} catch (Error $ex) {
\OC::$server->getLogger()->logException($ex, array('app' => 'index'));
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
OC_Template::printExceptionErrorPage($ex);
}

Ich bin mir sicher, nichts falsch gemacht zu haben, was PHP betrifft, ich hab' alle aufgelisteten Pakete installiert ohne eine Fehlermeldung oder sonstwas zu bekommen.
php7.0-fpm php7.0-gd php7.0-mysql php7.0-curl php7.0-xml php7.0-zip php7.0-intl php7.0-mcrypt php7.0-mbstring php7.0-bz2

MariaDB passt auch, wobei das hier eigentich irrelevant ist, das müsste ich erst eintragen wenn die Website an sich mal läuft.

Muss ich in nginx oder nextcloud noch irgendwas einstellen, ich finde diesbezüglich nichts relevantes.

Danke schonmal und LG:

Cazawhi
 
Auf welche Datei greift der Webserver denn zu?
Klingt ein wenig so, als wenn statt einer index.php eine index.html abgerufen wird.
 
  • Thread Starter Thread Starter
  • #3


/var/www/html/nextcloud/index.html:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"> window.location.href="index.php"; </script>
<meta http-equiv="refresh" content="0; URL=index.php">
</head>
</html>

Er greift (laut link) auf index.php zu.
 
Lohnt sich sicherlich auszuprobieren, aber das sind eigentlich korrekte JS und HTML5 Weiterleitungen.
Klingt danach, als wenn der webserver (nginx offenbar) nicht korrekt konfiguriert ist. Wird nginx alleine als normaler HTTP Webserver eingesetzt oder in Kombination mit z.B. Apache?
 
@Cazawhi: Ich bin jetzt nicht so firm mit nginx, aber bei apache2 reicht es nicht, PHP zu installieren - man muss die Module auch aktivieren. Eventuell ist das bei nginx auch so.
 
  • Thread Starter Thread Starter
  • #8
Das ist jetzt meine /etc/nginx/sites-available/default-Konfiguration, die ich laut einer Anleitung angepasst habe:
server {
listen 80 default_server;
listen [::]:80 default_server;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See:
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See:
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm;

server_name _;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}

# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;

# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
Jetzt kommt statt der nginx-default-seite nurnoch 403 forbidden und immernoch der index.php, aber jetzt als Download wenn ich /nextcloud öffne. dafuq
Nachtrag: Bei /nextcloud kommt jetzt Fehler 503.
 
@Cazawhi: Gibt es den Ordner mods-available bzw. mods-enabled? Wenn ja, dort PHP aktivieren. BTW: sites-available ist nicht sites-enabled. Available bedeutet, das System könnte die Seite ausliefern. Enabled heißt, dass es das auch tut.
 
  • Thread Starter Thread Starter
  • #10
modules-available ist leer,
In modules-enabled gibts:
[src=bash]50-mod-http-auth-pam.conf 50-mod-http-image-filter.conf 50-mod-mail.conf
50-mod-http-dav-ext.conf 50-mod-http-subs-filter.conf 50-mod-stream.conf
50-mod-http-echo.conf 50-mod-http-upstream-fair.conf
50-mod-http-geoip.conf 50-mod-http-xslt-filter.conf[/src]
 
nginx hat keine php integration in dem sinne, was auch ganz gut so ist, die php engine hat im webserver absolut nichts verloren, lässt sich aber mittels fcgi "nachrüsten".

Dafür einmal php-fpm installieren und ggf. starten. Die nginx config sollte dafür schon passen, wenn ich das richtig sehe.
Wichtig ist dafür dieser teil:
[src=text]location ~ \.php$ {
include snippets/fastcgi-php.conf;

# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

}[/src]
 
  • Thread Starter Thread Starter
  • #12
php-fpm installiert, nginx neu gestartet, immernoch auf der Hauptseite 403 und auf /nextcloud 503.
 
Man sollte sich auch mal anschauen, da steht auch noch was zur Konfiguration von nginx.
 
  • Thread Starter Thread Starter
  • #14
Welche Datei soll man da bearbeiten? Die /etc/nginx/nginx.conf sowie auch die /etc/nginx/sites-enabled/default sind anders aufgebaut,
 
in die sites-enabled/default, da du es vom default vhost serven willst, aber natürlich nicht blind rein kopieren.
Im wesentlich sollten alle location und die add_header direktiven übernommen werden, aber ggf müssen pfade und so angepasst werden.

Aber vorher sollte die Fehlermeldungen ausgemerzt werden.
Schau doch bitte einmal in den nginx error log und den php-fpm log ob es da hinweise auf die Ursachen gibt.

Hier schonmal ein hinweis:
403: Access Forbidden das kann bedeuten das die nginx config das verbietet oder auch das die Berechtigungen im Dateisystem nicht passen.
 
  • Thread Starter Thread Starter
  • #16
Genannte Config angepasst, danke :)
Hier ein Auszug aus dem Error Log (scheint relevant zu sein)
#0 {main}
thrown in /var/www/html/nextcloud/index.php on line 61" while reading response header from upstream, client: 192.168.3.10, server: _, request: "GET /nextcloud/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "192.168.3.1"
2017/09/04 21:50:38 [error] 9672#9672: *1 directory index of "/var/www/html/" is forbidden, client: 192.168.3.10, server: _, request: "GET / HTTP/1.1", host: "192.168.3.1"

Die Rechte an /var/www/html sind 775 und Besitzer ist www-data sowie auch Gruppe www-data.
 
Der 403 ist nun recht eindeutig, da ist schlicht keine index datei im Ordner und den Ordnerinhalt anzeigen darf er nicht.
Ist nicht weiter wild, aber einfach zum testen könntest du eine index.html mit beliebigen Inhalt erzeugen, die sollte dann auch ausgeliefert werden.

Der 503er ist mir allerdings noch nicht ganz klar.
hast du auch in den php-fpm log geschaut?
wenn da auch was drin steht wäre das durchaus noch interessant.

Außerdem wäre es gut wenn du einfach mal ein so genannte php info datei erstellst, dann können wir erst mal die zu laufen bringen, um alles weitere kann man sich dann kümmern.
Dafür einfach im webroot eine Datei mit folgendem Inhalt erstellen und einmal in Browser aufrufen, anschliessend bitte nochmal in die logs gucken.
[src=php]<?php
phpinfo();
?>[/src]
Da dieses php script allerdings sensible Daten offenbart solltest du es löschen sobald es nicht mehr gebraucht wird.
 
  • Thread Starter Thread Starter
  • #19
Da ist aber 'ne index.html im Ordner.
[src=html4strict]<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"> window.location.href="index.php"; </script>
<meta http-equiv="refresh" content="0; URL=index.php">
</head>
</html>[/src]





Zur Testdatei: Der Inhalt wird sauber dargestellt, es gibt einen sauberen Eintrag im acess.log, keine Einträge im error.log von nginx.
PHP legt nur eine Logdatei an, die sich auf Ein- und Ausschalten beschränkt.
 
Existiert denn der socket am in der Stelle wie in der nginx config angegeben?
Ist der php7 Dienst gestartet? (Php fpm ist ein eigenständig laufender Dienst, dieser muss dann auch auf unix socket konfiguriert sein, kann auch auf einem tcp socket laufen)
 
Zurück
Oben