malawi
Goto Top

Webserver (Nextcloud) unter Raspian, PHP7 und nginx

Hallo,

ich möchte mir einen kleinen Webserver auf einem RasperryPi einrichten um dann von überall auf diesen Kleinen zugreifen zu können.

Ich habe dazu folgende Anleitung herausgesucht:

Anleitung Nextcloud auf Raspi

Leider hänge ich bei Punkt 4.3, bei dem ich auf folgende weitere Anleitung vom selben Blogbetreiber geleitet werde:

Let's Encrypt Zertifikat

Bei dieser Anleitung hänge ich aktuell beim Punkt wo ich folgende Codezeile im Terminal ausführen möchte:

sudo certbot certonly --rsa-key-size 4096 --webroot -w /var/www/letsencrypt -d eureDomain.de -d www.eureDomain.de

Natürlich ist unter "eureDomain" mein Domänenname eureDomain.ddnss.de eingegeben.

Folgende Fehlermeldung bzw. Ausgabe:

2018-03-29 19_18_13-frage hinzufügen - kevische - administrator

Folgende Einstellungen habe ich bei meinem DynDNS-Anbieter "ddnss" eingestellt:

2018-03-29 19_21_24-dyndns - service _ dashboard

Ich muss gestehen, dass ich nicht viel Ahnung von Webservern habe, das kleine Projekt aber doch gerne schaffen möchte. Ich hoffe es kann mir jemand zur Seite stehen.

Vielen Dank!

Content-Key: 369701

Url: https://administrator.de/contentid/369701

Ausgedruckt am: 19.03.2024 um 08:03 Uhr

Mitglied: Tezzla
Tezzla 29.03.2018 um 20:48:13 Uhr
Goto Top
Hallo,

ist dein Raspi aus dem Internet über Port 80 und 443 erreichbar?
LetsEncrypt prüft beim Erstellen die Gegenstelle darüber und meckert in deinem Screen auch eine fehlende Verbindung zum Client an.

Viele Grüße
T
Mitglied: malawi
malawi 29.03.2018 um 21:20:42 Uhr
Goto Top
Zitat von @Tezzla:

Hallo,

ist dein Raspi aus dem Internet über Port 80 und 443 erreichbar?

Ich habe mir die Fehlermeldung auch nochmal genauer angesehen. Ich habe gerade gemerkt, dass der Webserver nichtmal intern über seine IP erreicht werden kann. Dabei habe ich folgendes in die Datei /etc/nginx/sites-available/default kopiert:

upstream php-handler {
server unix:/run/php/php7.0-fpm.sock;
}
 
server {
    listen 80;
    server_name cloud.example.com;
    # enforce https
    return 301 https://$server_name$request_uri;
}
 
server {
    listen 443 ssl http2;
    server_name cloud.example.com;
 
    ssl_certificate /etc/ssl/nginx/cloud.example.com.crt;
    ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key;
 
    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    # add_header Strict-Transport-Security "max-age=15768000; 
    # includeSubDomains; preload;"; 
    #
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";  
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;
 
    # Path to the root of your installation
    root /var/www/html/nextcloud/;
 
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
 
    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.  
    #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
    # last;
 
    location = /.well-known/carddav {
      return 301 $scheme://$host/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host/remote.php/dav;
    }
 
    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;
 
    # Enable gzip but do not remove ETag headers
    gzip on;
    gzip_vary on;
    gzip_comp_level 4;
    gzip_min_length 256;
    gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
    gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
 
    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;
 
    location / {
        rewrite ^ /index.php$uri;
    }
 
    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
        deny all;
    }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }
 
    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        #Avoid sending the security headers twice
        fastcgi_param modHeadersAvailable true;
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }
 
    location ~ ^/(?:updater|ocs-provider)(?:$|/) {
        try_files $uri/ =404;
        index index.php;
    }
 
    # Adding the cache control header for js and css files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|js|woff|svg|gif)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "public, max-age=15778463";  
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into
        # this topic first.
        # add_header Strict-Transport-Security "max-age=15768000; 
        #  includeSubDomains; preload;";  
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";  
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        # Optional: Don't log access to assets  
        access_log off;
    }
 
    location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don't log access to other assets  
        access_log off;
    }
}

So ist es in der oben angegebenen Beschreibung vorgegeben. Ich denke aber, dass dafür auch der SSL-Zugang schon bestehen muss. Wäre es nicht im ersten Schritt sinnvoller, den Webserver intern verfügbar zu machen? Da ich wirklich blutiger Anfänger bin, wäre meine Frage, was ich in die oben angegebene Datei schreiben muss, sodass ich erst einmal intern Zugriff habe...

Danke!
Mitglied: nEmEsIs
nEmEsIs 29.03.2018 aktualisiert um 22:39:10 Uhr
Goto Top
Hi

Hast du Server_name angepasst in deiner oben genannten konfig?
Kann es sein das deine Firewall auf dem PI noch an ist bzw 80 ubd 443 nicht offen sind ?
Ist der Dienst vom nginx gestartet ?
Service nginx Status
Wie sieht deine hosts Datei aus bzw wie ist dein hostname?

Trag mal deine Lokale IP anstatt des servernamens an.
Bitte nicht vergessen den ngnix neu zu starten.

Mit freundlichen Grüßen Nemesis
Mitglied: aqui
aqui 29.03.2018 um 22:54:29 Uhr
Goto Top
In der Februar ct' waren recht gute Artikel zum Thema Lets Encrypt und deren Automatisierung:
https://www.heise.de/ct/ausgabe/2018-4-SSL-TLS-Zertifikate-gratis-fuer-a ...
https://www.heise.de/ct/ausgabe/2018-4-acme-sh-bezieht-Wildcard-Zertifik ...

Lokal rennt der nginx aber schon, oder ? Kannst du den über seine lokale IP erreichen ?
Der nginx rennt eigentlich out of the box wenn man den mit apt-get install nginx installiert.
Mitglied: malawi
malawi 30.03.2018 um 08:45:30 Uhr
Goto Top
Zitat von @nEmEsIs:
Hast du Server_name angepasst in deiner oben genannten konfig?
Aktuell habe ich dort 192.168.2.4, also die lokale IP-Adresse hinterlegt.

Kann es sein das deine Firewall auf dem PI noch an ist bzw 80 ubd 443 nicht offen sind ?
Firewall habe ich keine aktiviert, wenn diese also nicht von Haus aus aktiviert ist, sollte da noch nichts laufen.
2018-03-30 08_18_48-pi@raspberrypi_ ~

Ist der Dienst vom nginx gestartet ?
Service nginx Status
2018-03-30 08_29_37-pi@raspberrypi_ ~

Wie sieht deine hosts Datei aus bzw wie ist dein hostname?
Der Hostname lautet ganz schlicht 'rasperrypi'

Trag mal deine Lokale IP anstatt des servernamens an.
Bitte nicht vergessen den ngnix neu zu starten.
Habe ich getan, kann aber den nginx Dienst nicht neustarten, siehe oben.


Das Video dazu habe ich bereits gesehen. Die Artikel lese ich mir mal durch, danke!

Lokal rennt der nginx aber schon, oder ? Kannst du den über seine lokale IP erreichen ?
Siehe oben.
Der nginx rennt eigentlich out of the box wenn man den mit apt-get install nginx installiert.
Ja, nachdem ich ihn frisch installiert hatte, ging er auch. Ich konnte ihn auch über die IP im Browser erreichen. Ich bin eben nach der im Eingangspost angegebenen Anleitung vorgegangen und hänge an dem Punkt Zertifikate erstellen. Ich vermute, dass der Fehler in dieser /etc/nginx/sites-available/default Datei liegt, da dort ja bereits Zertifikate hinterlegt sind, die ich noch gar nicht habe und mein Domänennamen da auch nicht hinterlegt ist. War halt so in der Beschreibung. Kann das überhaupt funktionieren? Außerdem ist oben unter Server eine Umleitung von HTTP auf HTTPS eingestellt ist, wenn ich das richtig interpretiere.

Das ist halt das Problem, wenn man etwas stur nach Anleitung machen möchte. Wenn das Verständnis fehlt, hörts auf. Hier einmal die Freigabe in meiner FritzBox:
2018-03-30 08_25_17-fritz!box 7430

Mich wundert der 64553er Port, obwohl ich beim Erstellen den Port 443 angegeben habe bzw. er automatisch ausgewählt wurde. Dazu muss ich sagen, dass ich noch ein Synology-NAS im Netzwerk habe, auf dem ein Synology-DynDNS Dienst eingerichtet ist. Dort ist also auch schon ein Webserver installiert. Den dort hinterlegten Inhalt erreiche ich auch mit der neuen DDNSS-Adresse. Aber wenn ich diese Synology ausschalte, dann sollte er doch die HTTP und HTTPS Anfragen an meinen Rasperry weiterleiten, oder sehe ich das falsch (Codezeile 9) ?

Hier nochmal der aktuelle Inhalt der Datei /etc/nginx/sites-available/default:

upstream php-handler {
server unix:/run/php/php7.0-fpm.sock;
}
 
server {
    listen 80;
    server_name 192.168.2.4;
    # enforce https
    return 301 https://$server_name$request_uri;
}
 
server {
    listen 443 ssl http2;
    server_name cloud.example.com;
 
    ssl_certificate /etc/ssl/nginx/cloud.example.com.crt;
    ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key;
 
    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    # add_header Strict-Transport-Security "max-age=15768000; 
    # includeSubDomains; preload;"; 
    #
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";  
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;
 
    # Path to the root of your installation
    root /var/www/html/nextcloud/;
 
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
 
    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.  
    #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
    # last;
 
    location = /.well-known/carddav {
      return 301 $scheme://$host/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host/remote.php/dav;
    }
 
    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;
 
    # Enable gzip but do not remove ETag headers
    gzip on;
    gzip_vary on;
    gzip_comp_level 4;
    gzip_min_length 256;
    gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
    gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
 
    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;
 
    location / {
        rewrite ^ /index.php$uri;
    }
 
    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
        deny all;
    }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }
 
    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        #Avoid sending the security headers twice
        fastcgi_param modHeadersAvailable true;
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }
 
    location ~ ^/(?:updater|ocs-provider)(?:$|/) {
        try_files $uri/ =404;
        index index.php;
    }
 
    # Adding the cache control header for js and css files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|js|woff|svg|gif)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "public, max-age=15778463";  
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into
        # this topic first.
        # add_header Strict-Transport-Security "max-age=15768000; 
        #  includeSubDomains; preload;";  
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";  
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        # Optional: Don't log access to assets  
        access_log off;
    }
 
    location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don't log access to other assets  
        access_log off;
    }
}

Danke für die Hilfe!
Mitglied: malawi
malawi 30.03.2018 um 09:11:15 Uhr
Goto Top
Kleines Update:

Ich habe die Codezeilen 9, 16 und 17 auskommentiert und konnte den Webserver dann auch Neustarten.

Jetzt kann ich über die interne IP auf meinen Webserver zugreifen...("Welcome to nginx...")
2018-03-30 09_14_17-
Mitglied: aqui
aqui 30.03.2018 um 09:15:42 Uhr
Goto Top
Dann nur noch PHP scharf schalten...
Datei info.php mit dem Inhalt:
<?php
phpinfo();
?>

erstellen und über den Browser aufrufen face-wink
Mitglied: malawi
malawi 30.03.2018 aktualisiert um 09:44:09 Uhr
Goto Top
Zitat von @aqui:

Dann nur noch PHP scharf schalten...
Datei info.php mit dem Inhalt: <?php
phpinfo();
?>

erstellen und über den Browser aufrufen face-wink

Die PHP-Datei habe ich erstellt und ins Verzeichnis meines Webservers gelegt. Wenn ich die Seite intern/extern Aufrufe:

meineDomain.ddnss.de/info.php bekomme ich den ErrorCode 404.

Edit:

Habe den Port in der FritzBox jetzt auf 443 statt 64533. Benötige ich nicht wenigstens ein selbst erstelltes Zertifikat um über HTTPS zugreifen zu können?
Mitglied: Tezzla
Tezzla 30.03.2018 um 21:57:55 Uhr
Goto Top
Der Reihe nach:

Wo genau hast du die phpinfo hingelegt?

Die Seite sollte auch über http und Port 80 erreichbar sein.
Erstmal deinen Webserver lokal ordentlich machen, dann den externen Zugriff.
Mitglied: aqui
aqui 31.03.2018 aktualisiert um 00:19:19 Uhr
Goto Top
bekomme ich den ErrorCode 404.
Die Änderungen an der nginx Konfig Datei hast du aber gemacht damit nginx überhaupt PHP versteht ?
https://www.howtoforge.de/anleitung/installation-von-nginx-mit-php5-und- ...
Hier die angepasste /etc/nginx/sites-available/default auf einem Raspberry Pi:
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #
        #       # With php5-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
} 
Die dort aufgeführte Änderung der /etc/nginx/nginx.conf ist nicht erforderlich.
Mitglied: malawi
malawi 31.03.2018 um 12:46:50 Uhr
Goto Top
Zitat von @Tezzla:

Der Reihe nach:
Ja bitte face-smile

Wo genau hast du die phpinfo hingelegt?
Die liegt aktuell unter /var/www/html. Genauso wie eine von mir erstellte index.html Datei, welche lediglich "test" als Text anzeigen soll.
Wenn ich jetzt im Browser über http://192.168.2.4 den Webserver aufrufe, dann bekomme ich aber nicht meine selbst erstellte HTML-Seite zurück, sondern nach wie vor die Default-NGINX-index.html. Was mich etwas wundert, da ich diese bereits entfernt habe.

In der /etc/nginx/sites-available/default habe ich folgendes als Root-Verzeichnis stehen:

 # Path to the root of your installation
    root /var/www/html/;
2018-03-31 12_36_19-192.168.2.4 - remotedesktopverbindung

Ich habe ja oben auch mal den kompletten Inhalt meiner /etc/nginx/sites-available/default gepostet. Da kann man entnehmen, was ich bereits dort eingefügt habe. Aber wie gesagt, eben stur nach Anleitung vorgegangen, weil ich selbst noch wenig Ahnung habe.

Die Seite sollte auch über http und Port 80 erreichbar sein.
Momentan ist die Seite nur über http aufrufbar. Zwar ist sie auch über https aufrufbar, allerdings zeigt mir der Browser dann an "file not found". Aktuell habe ich noch ein selbst erstelltes Zertifikat. Was ja später mal durch ein letsencrypt-Zertifikat ersetzt werden soll.

Erstmal deinen Webserver lokal ordentlich machen, dann den externen Zugriff.
Ich danke dir für die Unterstützung!


Zitat von @aqui:
Die Änderungen an der nginx Konfig Datei hast du aber gemacht damit nginx überhaupt PHP versteht ?
Wie gesagt, oben steht der komplette Inhalt meiner /etc/nginx/sites-available/default. Ganz am Anfang steht was mit PHP, aber ob das so passt und ausreicht, weiß ich nicht, da das für mich aktuell wirklich noch sehr kryptisch ist.
https://www.howtoforge.de/anleitung/installation-von-nginx-mit-php5-und- ...
Hier die angepasste /etc/nginx/sites-available/default auf einem Raspberry Pi:
>         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
>         #
>         location ~ \.php$ {
>                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
>         #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
>         #
>         #       # With php5-cgi alone:
>         #       fastcgi_pass 127.0.0.1:9000;
>         #       # With php5-fpm:
>                 fastcgi_pass unix:/var/run/php5-fpm.sock;
>                 fastcgi_index index.php;
>                 include fastcgi_params;
>         }
> 
>         # deny access to .htaccess files, if Apache's document root
>         # concurs with nginx's one
>         #
>         #location ~ /\.ht {
>         #       deny all;
>         #}
> } 
Die dort aufgeführte Änderung der /etc/nginx/nginx.conf ist nicht erforderlich.

Ich habe meinen Webserver mit PHP7 bestückt, weil ich direkt auf neuere Versionen von Nextcloud updaten können möchte. Ich weiß immer nicht, in wie weit ich diese Anleitung dann auf mein Projekt übernehmen kann.

Vielleicht sollte ich die /etc/nginx/sites-available/default einmal komplett leeren und nur das nötigste rein schreiben. Aber was das ist, weiß ich nicht.
Mitglied: aqui
aqui 31.03.2018 um 16:42:29 Uhr
Goto Top
Du hast ja deine HTML Document Root auf root /var/www/html/nextcloud/ gelegt.
Deshalb kann nginx deine beiden Test Dateien index.html und info.php nicht finden da die ja in /var/www/html liegen.
Du musst diese also ins Document Root Verzeichnis kopieren. Dann sollte das klappen.

Hast du mit apt-get install php7-cgi php7-fpm die PHP cgi und fpm Pakete installiert ?
Mitglied: malawi
malawi 31.03.2018 um 19:52:22 Uhr
Goto Top
Zitat von @aqui:

Du hast ja deine HTML Document Root auf root /var/www/html/nextcloud/ gelegt.
Deshalb kann nginx deine beiden Test Dateien index.html und info.php nicht finden da die ja in /var/www/html liegen.
Du musst diese also ins Document Root Verzeichnis kopieren. Dann sollte das klappen.
Das habe ich bereits geändert. Siehe meinen letzten Beitrag. Geht dennoch auch nach Neustart des Server-Dienstes noch nicht.

Hast du mit apt-get install php7-cgi php7-fpm die PHP cgi und fpm Pakete installiert ?
Ich habe folgendes Befehl aus der Anleitung übernommen zwecks PHP:
apt-get install php7.0-common php7.0-fpm php7.0-cli php7.0-json php7.0-mysql php7.0-curl php7.0-intl php7.0-mcrypt php-pear php7.0-gd php7.0-zip php7.0-xml php7.0-mbstring
Mitglied: aqui
aqui 31.03.2018 um 22:09:20 Uhr
Goto Top
Geht dennoch auch nach Neustart des Server-Dienstes noch nicht.
Ungewöhnlich ?!
Wo steht denn die Default index.html ?? Die funktioniert doch, oder ?
Genau DA müssen auch die anderen beiden Files auch hin.
Mitglied: malawi
malawi 01.04.2018 aktualisiert um 16:15:47 Uhr
Goto Top
Zitat von @aqui:
Wo steht denn die Default index.html ?? Die funktioniert doch, oder ?
Genau DA müssen auch die anderen beiden Files auch hin.

Mich wundert es auch, da ich in /var/www/html nur zwei Dateien liegen habe. Meine beiden index.html (funktioniert) und info.php (konnte ich noch nicht testen). Es liegt nichts anderes in diesem Ordner und trotzdem wird die Willkommensseite von NGINX angezeigt. Ich finde diese Willkommens-HTML auch nirgends. Das ist sehr seltsam...

Hier nochmal der Bereich des Pfades in der /etc/nginx/sites-available/default:

# Path to the root of your installation
    root /var/www/html;
 
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

Dienst-Neustart und kompletter Reboot bringen keine Änderungen. Es kann doch dann nur ein anderes Verzeichnis das Root-Verzeichnis sein oder nicht?

EDIT
Ich habe inzwischen herausgefunden, dass der Webserver anzeigt, was in /usr/share/nginx/html liegt.
Mitglied: aqui
aqui 01.04.2018 um 21:25:15 Uhr
Goto Top
Klingt irgendwie nach einer recht verwarzten HTTP Server Konfig.
Ich hatte das hier auf einem RasPi (Debian) getestet und da rennt alles fehlerfrei wie es soll !
Mitglied: malawi
malawi 02.04.2018 um 16:12:06 Uhr
Goto Top
Zitat von @aqui:
Klingt irgendwie nach einer recht verwarzten HTTP Server Konfig.
Ich hatte das hier auf einem RasPi (Debian) getestet und da rennt alles fehlerfrei wie es soll !

Ich habe nginx einmal komplett deinstalliert:
apt remove --purge nginx nginx-common nginx-full

und dann wieder neu installiert:
apt install nginx

Die default Config-Datei ist nun wieder die Standard von nginx. Allerdings wird nach wie vor der Pfad /usr/share/nginx/html als Webspace aufgerufen, obwohl in der default Config-Datei bereits folgendes steht:

root /var/www/html

Dann greift diese Config-Datei nicht, anders kann ich mir das nicht erklären.

Kann es vielleicht damit zusammenhängen, dass folgendes installiert ist:

2018-04-02 16_07_38-pi@raspberrypi_ _usr_share_nginx_html

Ist das nicht auch ein Webserver? Den habe ich gerade in einer Liste entdeckt. Wurde aber von mir nicht wissentlich installiert.
Mitglied: aqui
aqui 02.04.2018 um 19:07:29 Uhr
Goto Top
Ist das nicht auch ein Webserver?
Ja !
Das kann dann natürlich nicht klappen, denn beide streiten sich dann um den HTTP Port TCP 80 und 443.
Es sei denn einer von denen nutzt andere Ports.
Den lighttpd solltest du dann natürlich sofort runterschmeissen. Das ist vermutlich genau der Fehler.
Wozu ist der überhaupt installiert ? Eigentlich Unsinn.
Mitglied: malawi
malawi 03.04.2018 um 10:10:56 Uhr
Goto Top
Zitat von @aqui:

Das kann dann natürlich nicht klappen, denn beide streiten sich dann um den HTTP Port TCP 80 und 443.
Es sei denn einer von denen nutzt andere Ports.
Den lighttpd solltest du dann natürlich sofort runterschmeissen. Das ist vermutlich genau der Fehler.
Wozu ist der überhaupt installiert ? Eigentlich Unsinn.

Ich weiß nicht wo der her kommt. Ich habe ihn nicht wissentlich installiert. Er war also entweder bei Rasbian schon vorinstalliert oder er wurde durch ein anderes Paket (nginx, php7.0, mysql) mit installiert. Ich habe jetzt minimal Rasbian installiert und fang nochmal von vorne an.
Mitglied: aqui
aqui 03.04.2018 um 14:35:41 Uhr
Goto Top
Damit klappt es sofort ! face-wink Siehe oben...
Aber auch mit einem Debian oder Xubuntu kommt es sofort zum Fliegen.
Mitglied: malawi
malawi 03.04.2018 aktualisiert um 20:24:18 Uhr
Goto Top
Zitat von @aqui:

Damit klappt es sofort ! face-wink Siehe oben...
Aber auch mit einem Debian oder Xubuntu kommt es sofort zum Fliegen.


Also jetzt rennt er face-smile auch mit Letsencrypt Zertifikat...perfekt!
Bis hierher gilt schon einmal ein recht herzliches Dankeschön!

Wenn ich jetzt PHP7.0 als Paket installieren möchte, dann will er mir z.B. auch apache2 mit installieren. Muss ich hier die Pakete einzeln angeben oder gibt es einen speziellen Befehl?

Ich kenne die minimal benötigten Pakete nicht.

EDIT:
Was ist denn der Unterschied zwischen PHP7.0-fpm und PHP7.0-cgi ?
Mitglied: aqui
aqui 04.04.2018 aktualisiert um 10:38:25 Uhr
Goto Top
Du benötigst nur PHP7.0-fpm ! Dann installiert er dir auch nur die minimal dafür nötigen PHP7 Pakete und nicht das gesamte Meta Paket. Apache2 ist natürlich überflüssig für dich...schlimmer noch der bringt dir wieder das gleiche Desaster wie mit dem lighttpd ! face-wink
Mitglied: malawi
malawi 04.04.2018 um 20:17:45 Uhr
Goto Top
Also, PHP hat soeben auch funktioniert. Jetzt habe ich noch MariaDB installiert und eine Datenbank angelegt. Nun geht es an Nextcloud:

etc/nginx/sites-available/default -- Inhalt:

upstream php-handler {
    server 127.0.0.1:9000;
    server unix:/var/run/php5-fpm.sock;
}

server {
    listen 80;
    listen [::]:80;
    server_name cloud.example.com;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name cloud.example.com;

    ssl_certificate /etc/ssl/nginx/cloud.example.com.crt;
    ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key;

    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    # add_header Strict-Transport-Security "max-age=15768000; 
    # includeSubDomains; preload;"; 
    #
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";  
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;

    # Path to the root of your installation
    root /var/www/nextcloud/;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.  
    #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
    # last;

    location = /.well-known/carddav {
      return 301 $scheme://$host/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host/remote.php/dav;
    }

    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;

    # Enable gzip but do not remove ETag headers
    gzip on;
    gzip_vary on;
    gzip_comp_level 4;
    gzip_min_length 256;
    gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
    gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;

    location / {
        rewrite ^ /index.php$uri;
    }

    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
        deny all;
    }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }

    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        #Avoid sending the security headers twice
        fastcgi_param modHeadersAvailable true;
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }

    location ~ ^/(?:updater|ocs-provider)(?:$|/) {
        try_files $uri/ =404;
        index index.php;
    }

    # Adding the cache control header for js and css files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|js|woff|svg|gif)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "public, max-age=15778463";  
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into
        # this topic first.
        # add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";  
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";  
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        # Optional: Don't log access to assets  
        access_log off;
    }

    location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don't log access to other assets  
        access_log off;
    }
}

Die Zeilen 9, 17, 19, 20 habe ich angepasst. Nun bekomme ich eine "502 Bad Gateway" Fehlermeldung vom Browser zurück. Es ist wirklich zum Haare raufen.

Den angegebenen Inhalt der Default-Datei habe ich aus folgender Seite: klick

Was soll ich noch anders machen? Ich kopiere doch nur face-sad

Der einzige Unterschied welcher mir auffällt ist, dass ich keine .cert und .key sonder zweimal .pem Zertifikate habe. Ist das relevant? Mit diesen Zertifikaten ging es vor dem kopieren des Quelltextes ja mit HTTPS auf den Webserver zuzugreifen.

Ich hoffe ihr könnt mich auch hier in die richtige Richtung schupsen...