Skip to content

Installation von Grav & NGinx & PHP7.2

Pinned Moved Grav
  • Wird nochmal überarbeitet, da ich noch über einige Probleme gestolpert bin! Für Einsteiger im Moment nur bedingt zu empfehlen!

    Ich hatte schon mal auf einem Debian System PHP7 installiert -> https://frank-mankel.de/kategorien/15-joomla/202-debian-joomla-mit-php7-auf-nginx

    Nun habe ich das auf einem ROCKPro64 gemacht und ein wenig Kopfschmerzen bekommen 😉 Ziel des Ganzen ist es eine Grav-Installation zum Laufen zu bekommen.

    Hardware

    • ROCKPro64 v2.0

    Software

    Linux

    rock64@rockpro64v2_0:~$ uname -a
    Linux rockpro64v2_0 4.4.132-1081-rockchip-ayufan-g50be7e64a779 #1 SMP Tue Jul 31 20:09:25 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux
    

    NGinx

    rock64@rockpro64:~$ nginx -v
    nginx version: nginx/1.14.0 (Ubuntu)
    

    PHP

     rock64@rockpro64:~$ php -v
     PHP 7.2.7-0ubuntu0.18.04.2 (cli) (built: Jul  4 2018 16:55:24) ( NTS )
     Copyright (c) 1997-2018 The PHP Group
     Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
         with Zend OPcache v7.2.7-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies
    

    Installation

    NGinx

    sudo apt-get install nginx 
    

    PHP

    sudo apt-get install php7.2
    

    Benötigte Module für PHP

    sudo apt-get install php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml php7.2-xsl php7.2-zip
    sudo apt-get install php7.2-cli php7.2-curl php7.2-gd php7.2-geoip php7.2-intl php7.2-json php7.2-mbstring
    

    Konfiguration NGinx

    /etc/nginx/nginx.conf

    user www-data;
    worker_processes auto;
    worker_rlimit_nofile 8192; # should be bigger than worker_connections
    pid /run/nginx.pid;
    
    events {
        use epoll;
        worker_connections 8000;
        multi_accept on;
    }
    
    http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
    
        keepalive_timeout 30; # longer values are better for each ssl client, but take up a worker connection longer
        types_hash_max_size 2048;
        server_tokens off;
    
        # maximum file upload size
        # update 'upload_max_filesize' & 'post_max_size' in /etc/php5/fpm/php.ini accordingly
        client_max_body_size 32m;
        # client_body_timeout 60s; # increase for very long file uploads
    
        # set default index file (can be overwritten for each site individually)
        index index.html;
    
        # load MIME types
        include mime.types; # get this file from https://github.com/h5bp/server-configs-nginx
        default_type application/octet-stream; # set default MIME type
    
        # logging
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
    
        # turn on gzip compression
        gzip on;
        gzip_disable "msie6";
        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 5;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_min_length 256;
        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;
        
        # disable content type sniffing for more security
        add_header "X-Content-Type-Options" "nosniff";
        
        # force the latest IE version
        add_header "X-UA-Compatible" "IE=Edge";
        
        # enable anti-cross-site scripting filter built into IE 8+
        add_header "X-XSS-Protection" "1; mode=block";
        
        # include virtual host configs
        include sites-enabled/*;
    }
    

    Unter /etc/nginx/sites-available die Datei default löschen. Die Datei grav-site anlegen.

    /etc/nginx/sites-available/grav-site

    server {
        #listen 80;
        index index.html index.php;
    
        ## Begin - Server Info
        root /var/www/grav;
        server_name localhost;
        ## End - Server Info
    
        ## Begin - Index
        # for subfolders, simply adjust:
        # `location /subfolder {`
        # and the rewrite to use `/subfolder/index.php`
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
        ## End - Index
    
        ## Begin - Security
        # deny all direct access for these folders
        location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
        # deny running scripts inside core system folders
        location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
        # deny running scripts inside user folder
        location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
        # deny access to specific files in the root folder
        location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
        ## End - Security
    
        ## Begin - PHP
        location ~ \.php$ {
            # Choose either a socket or TCP/IP address
            #fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
             fastcgi_pass 127.0.0.1:9000;
    
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
        }
        ## End - PHP
    }
    

    Danach brauchen wir einen symbolischen Link in /etc/nginx/sites-enabled Nur dann funktioniert eine Seite.

    sudo ln -s /etc/nginx/sites-available/grav-site /etc/nginx/sites-enabled/
    

    Installation Grav

    Core installieren
    Option 3 der Anleitung https://learn.getgrav.org/basics/installation

    Admin Panel installieren
    https://learn.getgrav.org/admin-panel/introduction

    Meine Grav-Installation liegt unter

     /var/www/grav
    

    Womit hatte ich nun Probleme? NGinx dient ja als Webserver, dieser Webserver muss jetzt die PHP-Dateien entsprechend verarbeiten können. Dazu gibt es folgenden Block in der Datei /etc/nginx/sites-available/grav-site

     ## Begin - PHP
         location ~ \.php$ {
             # Choose either a socket or TCP/IP address
             #fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
              fastcgi_pass 127.0.0.1:9000;
     
             fastcgi_split_path_info ^(.+\.php)(/.+)$;
             fastcgi_index index.php;
             include fastcgi_params;
             fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
         }
         ## End - PHP
    

    Es war vorher folgendermaßen

    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    #fastcgi_pass 127.0.0.1:9000;
    

    Das hat nicht geklappt. Was sagt die Ubuntu Seite dazu?? Man soll folgendes machen. Datei /usr/local/bin/php-fastcgi anlegen.

     #!/bin/bash
     php-cgi -b 127.0.0.1:9000
    

    Ausführungsrechte

    chmod a+x /usr/local/bin/php-fastcgi 
    

    Danach starten

     sudo php-fastcgi 
    

    Das funktioniert aber nur, wenn folgendes eingestellt ist.

    #fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_pass 127.0.0.1:9000;
    

    Damit wird PHP direkt an die FastCGI-Schnittstelle gebunden.

    Quelle: https://wiki.ubuntuusers.de/nginx/PHP/

    Danach lief meine Grav-Installation.

    0_1532448808009_Grav_ergebnis.jpg

    So weit so gut. Ein kleiner Schönheitsfehler. Konsole zu beendet

    sudo php-fastcgi 
    

    dann war es das wieder mit NGinx. Die Lösung wir brauchen eine Datei /etc/rc.local

    #!/bin/bash
    #
    # rc.local - executed at the end of each multiuser runlevel
    #
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    php-fastcgi 
    exit 0
    

    Den Dienst dann nach dieser Anleitung einrichten

    Danach den Server neu starten und es funktioniert!

    Achtung! Nicht auf einem produktiven System einsetzen, ich bin mir nicht sicher ob das zu 100% sicher ist.

  • Nachdem ich den ROCKPro64 jetzt auf den Mainline umgestellt habe, lief meine Testinstallation von Grav nicht mehr.

    Hilfreiche Sache um das Problem zu lösen -> https://gist.github.com/GhazanfarMir/03bd1f1f770a3834d47274586d46ea62

    Ich bekam immer 502 Bad Gateway, Grund war ein nicht korrekt gestarteter php-pfm Service.

    rock64@rockpro64v2_0:/usr/local/bin$ sudo service php7.2-fpm start
    rock64@rockpro64v2_0:/usr/local/bin$ sudo service php7.2-fpm status
    ● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
       Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled)
       Active: active (running) since Thu 2018-08-16 20:15:20 CEST; 21s ago
         Docs: man:php-fpm7.2(8)
     Main PID: 3206 (php-fpm7.2)
       Status: "Processes active: 0, idle: 2, Requests: 3, slow: 0, Traffic: 0.2req/sec"
        Tasks: 3 (limit: 4622)
       CGroup: /system.slice/php7.2-fpm.service
               ├─3206 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
               ├─3207 php-fpm: pool www
               └─3208 php-fpm: pool www
    
    Aug 16 20:15:19 rockpro64v2_0 systemd[1]: Starting The PHP 7.2 FastCGI Process Manager...
    Aug 16 20:15:20 rockpro64v2_0 systemd[1]: Started The PHP 7.2 FastCGI Process Manager.
    

  • 0 Votes
    1 Posts
    116 Views
    No one has replied
  • 0 Votes
    2 Posts
    132 Views
    FrankMF

    Ich hasse schlecht lesbaren Code, scheint man sich bei Python so anzugewöhnen. Habe da nochmal was mit der langen Zeile getestet.

    stages: - deploy deploy: stage: deploy script: # $SEMAPHORE_API_TOKEN is stored in gitlab Settings/ CI/CD / Variables - >- curl -v XPOST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: Bearer $SEMAPHORE_API_TOKEN " -d '{"template_id": 2}' https://<DOMAIN>/api/project/2/tasks only: - master # Specify the branch to trigger the pipeline (adjust as needed)

    Hier noch was Dr. ChatGPT dazu schreibt

    631de9d4-b04d-4043-bfff-c5f2d1b6eea7-grafik.png

    Erledigt - läuft 🙂 Und verstanden habe ich es auch.

  • 0 Votes
    2 Posts
    73 Views
    FrankMF

    Und da sind wir schon bei RC4

    Debian Installer Bookworm RC 4 release

    favicon

    (lists.debian.org)

  • 0 Votes
    1 Posts
    141 Views
    No one has replied
  • Debian 11 Bullseye released!

    Linux
    4
    0 Votes
    4 Posts
    283 Views
    FrankMF

    Mein Systemadmin auf der Arbeit meinte heute, angesprochen auf das Problem, läuft der Network-Manager? Ok, gute Frage...... Schauen wir mal.

    Ich bin mir leider nicht 100% sicher, ob er vor meinem Eingreifen lief, ich denke aber schon. Warum ich unsicher bin?

    root@debian:~# systemctl enable systemd-networkd.service Created symlink /etc/systemd/system/dbus-org.freedesktop.network1.service → /lib/systemd/system/systemd-networkd.service. Created symlink /etc/systemd/system/multi-user.target.wants/systemd-networkd.service → /lib/systemd/system/systemd-networkd.service. Created symlink /etc/systemd/system/sockets.target.wants/systemd-networkd.socket → /lib/systemd/system/systemd-networkd.socket. Created symlink /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service → /lib/systemd/system/systemd-networkd-wait-online.service.

    Ok, danach

    root@debian:~# systemctl start systemd-networkd.service root@debian:~# systemctl status systemd-networkd.service ● systemd-networkd.service - Network Service Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; ven> Active: active (running) since Tue 2021-08-17 17:36:38 CEST; 6s ago TriggeredBy: ● systemd-networkd.socket Docs: man:systemd-networkd.service(8) Main PID: 1288 (systemd-network) Status: "Processing requests..." Tasks: 1 (limit: 19087) Memory: 3.9M CPU: 39ms CGroup: /system.slice/systemd-networkd.service └─1288 /lib/systemd/systemd-networkd Aug 17 17:36:38 debian systemd[1]: Starting Network Service... Aug 17 17:36:38 debian systemd-networkd[1288]: enp25s0: Gained IPv6LL Aug 17 17:36:38 debian systemd-networkd[1288]: Enumeration completed Aug 17 17:36:38 debian systemd[1]: Started Network Service.

    Danach ging immer noch nix.

    root@debian:/etc/network# ^C root@debian:/etc/network# nmcli device show GENERAL.DEVICE: wlx7cdd907cbec2 GENERAL.TYPE: wifi GENERAL.HWADDR: BA:59:C0:76:C7:F5 GENERAL.MTU: 1500 GENERAL.STATE: 20 (nicht verfügbar) GENERAL.CONNECTION: -- GENERAL.CON-PATH: -- GENERAL.DEVICE: enp25s0 GENERAL.TYPE: ethernet GENERAL.HWADDR: 30:9C:23:60:C6:8E GENERAL.MTU: 1500 GENERAL.STATE: 10 (nicht verwaltet) GENERAL.CONNECTION: -- GENERAL.CON-PATH: -- WIRED-PROPERTIES.CARRIER: an IP4.ADDRESS[1]: 192.168.3.169/24 IP4.GATEWAY: 192.168.3.1 IP4.ROUTE[1]: dst = 192.168.3.0/24, nh = 0.0.0.0, mt = 0 IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 192.168.3.1, mt = 0 IP6.ADDRESS[1]: 2a02:908:1260:13bc:329c:23ff:xxxx:xxxx/64 IP6.ADDRESS[2]: fd8a:6ff:2880:0:329c:23ff:fe60:c68e/64 IP6.ADDRESS[3]: fe80::329c:23ff:fe60:c68e/64 IP6.GATEWAY: fe80::e4d3:f0ff:fe8f:2354 IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 256 IP6.ROUTE[2]: dst = ::/0, nh = fe80::e4d3:f0ff:fe8f:2354, mt = 1024 IP6.ROUTE[3]: dst = 2a02:908:xxxx:xxxx::/64, nh = ::, mt = 256 IP6.ROUTE[4]: dst = fd8a:6ff:2880::/64, nh = ::, mt = 256

    Jetzt hatte ich das erste Mal einen Ansatz, wonach ich suchen musste.

    GENERAL.STATE: 10 (nicht verwaltet)

    Etwas Suche im Netz und dann das

    nano /etc/NetworkManager/NetworkManager.conf

    Inhalt der Datei

    [main] plugins=ifupdown,keyfile [ifupdown] managed=false

    Das false in true geändert. Danach ein

    systemctl restart NetworkManager

    und ich konnte den Network-Manager auf dem Desktop benutzen!?!?!?

    Bildschirmfoto vom 2021-08-17 18-07-25.png

    Irgendwas ist da durcheinander im Bullseye 😳

  • Debian Buster 10.6 released

    Linux
    1
    0 Votes
    1 Posts
    195 Views
    No one has replied
  • 0 Votes
    17 Posts
    1k Views
    FrankMF

    Durch diesen Beitrag ist mir mal wieder eingefallen, das wir das erneut testen könnten 😉

    Also die aktuellen Daten von Debian gezogen. Das Image gebaut, könnt ihr alles hier im ersten Beitrag nachlesen. Da die eingebaute Netzwerkschnittstelle nicht erkannt wurde, habe ich mal wieder den USB-to-LAN Adapter eingesetzt.

    Bus 005 Device 002: ID 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet

    Die Installation wollte ich auf einem NVMe Riegel installieren.

    Die Debian Installation durchgezogen und nach erfolgreicher Installation neugestartet. Und siehe da, ohne das man alles möglich ändern musste, bootete die NVMe SSD 🤓

    Eingesetzter uboot -> 2020.01-ayufan-2013......

    Die nicht erkannte LAN-Schnittstelle müsste an nicht freien Treibern liegen, hatte ich da irgendwo kurz gelesen. Beim Schreiben dieses Satzes kam die Nacht und ich konnte noch mal drüber schlafen. Heute Morgen, beim ersten Kaffee, dann noch mal logischer an die Sache ran gegangen.

    Wir schauen uns mal die wichtigsten Dinge an.

    root@debian:~# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 62:03:b0:d6:dc:b3 brd ff:ff:ff:ff:ff:ff 3: enx000acd26e2c8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0a:cd:26:e2:c8 brd ff:ff:ff:ff:ff:ff inet 192.168.3.208/24 brd 192.168.3.255 scope global dynamic enx000acd26e2c8 valid_lft 42567sec preferred_lft 42567sec inet6 fd8a:6ff:2880:0:20a:cdff:fe26:e2c8/64 scope global dynamic mngtmpaddr valid_lft forever preferred_lft forever inet6 2a02:908:1260:13bc:20a:xxxx:xxxx:xxxx/64 scope global dynamic mngtmpaddr valid_lft 5426sec preferred_lft 1826sec inet6 fe80::20a:cdff:fe26:e2c8/64 scope link valid_lft forever preferred_lft forever

    Ok, er zeigt mir die Schnittstelle eth0 ja an, dann kann es an fehlenden Treibern ja nicht liegen. Lässt dann auf eine fehlerhafte Konfiguration schließen. Nächster Halt wäre dann /etc/network/interfaces

    Das trägt Debian ein

    # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface allow-hotplug enx000acd26e2c8 iface enx000acd26e2c8 inet dhcp # This is an autoconfigured IPv6 interface iface enx000acd26e2c8 inet6 auto

    Gut, bei der Installation hat Debian ja nur die zusätzliche Netzwerkschnittstelle erkannt, folgerichtig ist die auch als primäre Schnittstelle eingetragen. Dann ändern wir das mal...

    # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface #allow-hotplug enx000acd26e2c8 allow-hotplug eth0 #iface enx000acd26e2c8 inet dhcp iface eth0 inet dhcp # This is an autoconfigured IPv6 interface #iface enx000acd26e2c8 inet6 auto iface eth0 inet6 auto

    Danach einmal alles neu starten bitte 😉

    systemctl status networking

    Da fehlte mir aber jetzt die IPv4 Adresse, so das ich einmal komplett neugestartet habe. Der Ordnung halber, so hätte man die IPv4 Adresse bekommen.

    dhclient eth0

    Nachdem Neustart kam dann das

    root@debian:/etc/network# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 62:03:b0:d6:dc:b3 brd ff:ff:ff:ff:ff:ff inet 192.168.3.172/24 brd 192.168.3.255 scope global dynamic eth0 valid_lft 42452sec preferred_lft 42452sec inet6 fd8a:6ff:2880:0:6003:b0ff:fed6:dcb3/64 scope global dynamic mngtmpaddr valid_lft forever preferred_lft forever inet6 2a02:908:1260:13bc:6003:xxxx:xxxx:xxxx/64 scope global dynamic mngtmpaddr valid_lft 5667sec preferred_lft 2067sec inet6 fe80::6003:b0ff:fed6:dcb3/64 scope link valid_lft forever preferred_lft forever 3: enx000acd26e2c8: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 00:0a:cd:26:e2:c8 brd ff:ff:ff:ff:ff:ff

    Fertig, eth0 läuft. Nun kann man den zusätzlichen Adapter entfernen oder halt konfigurieren, wenn man ihn braucht.

    Warum der Debian Installer die eth0 nicht erkennt verstehe ich nicht, aber vielleicht wird das irgendwann auch noch gefixt. Jetzt habe ich erst mal einen Workaround um eine Installation auf den ROCKPro64 zu bekommen.

  • 0 Votes
    1 Posts
    237 Views
    No one has replied