Skip to content

Installation von Grav & NGinx & PHP7.2

Angeheftet Verschoben 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.
    

  • Update 1.30.5 released

    Vaultwarden
    1
    0 Stimmen
    1 Beiträge
    98 Aufrufe
    Niemand hat geantwortet
  • FrOSCon 18 - Bericht

    Linux
    2
    0 Stimmen
    2 Beiträge
    118 Aufrufe
    FrankMF

    Und man soll ja auch was mitnehmen....

    Screenshot_20230809_194620.png

    Das ist Semaphore, installiert in einer VM auf meinem Proxmox.

  • Vorstellung Star64

    Hardware
    2
    0 Stimmen
    2 Beiträge
    54 Aufrufe
    FrankMF

    Ich konnte heute einen ergattern und die 8GB RAM Version ist unterwegs. Achtung, aktuell ist die Softwareunterstützung fast nicht vorhanden!

  • 1 Stimmen
    1 Beiträge
    203 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    1 Beiträge
    293 Aufrufe
    Niemand hat geantwortet
  • Restic & Rclone & Nextcloud

    Linux
    3
    0 Stimmen
    3 Beiträge
    688 Aufrufe
    FrankMF

    Hier mal eine Ausgabe vom ersten Durchgang

    root@frank-MS-7C37:~# restic --password-file /root/passwd -r rclone:Nextcloud:HOME_UBUNTU backup --files-from /root/includes.txt repository 99xxxxa0 opened successfully, password is correct created new cache in /root/.cache/restic rclone: 2020/05/08 17:47:57 ERROR : locks: error listing: directory not found rclone: 2020/05/08 17:47:58 ERROR : index: error listing: directory not found rclone: 2020/05/08 17:47:58 ERROR : snapshots: error listing: directory not found Files: 3503 new, 0 changed, 0 unmodified Dirs: 2 new, 0 changed, 0 unmodified Added to the repo: 16.872 GiB processed 3503 files, 21.134 GiB in 1:02:56 snapshot fdxxxxec saved

    Der erste Durchgang hat also etwa eine Stunde benötigt. Durch die Deduplikation der Daten, ist der Vorgang beim zweiten Durchgang viel schneller weil nur neue oder geänderte Daten gesichert werden. Und außerdem sind alle Daten AES-256 verschlüsselt. Also perfekt zur Ablage in irgendeiner Cloud 😉

    root@frank-MS-7C37:~# restic --password-file /root/passwd -r rclone:Nextcloud:HOME_UBUNTU backup --files-from /root/includes.txt repository 99xxxxa0 opened successfully, password is correct Files: 57 new, 41 changed, 3449 unmodified Dirs: 0 new, 2 changed, 0 unmodified Added to the repo: 22.941 MiB processed 3547 files, 21.137 GiB in 0:13 snapshot c6xxxxe4 saved

    Wie ihr seht, hat der zweite Durchgang nur ein paar neue und geänderte Daten gesichert. Der Rest ist ja schon vorhanden. Und das kann man dann auch problemlos täglich, wöchentlich oder was auch immer mal eben schnell durchführen.

    Eines meiner absoluten Lieblingstool 🙂

  • Liste von Linuxbefehlen

    Angeheftet Linux
    3
    0 Stimmen
    3 Beiträge
    637 Aufrufe
    FrankMF
    systemd Anzeige der geladenen Dienste root@host:/etc/systemd/system# systemctl --type=service UNIT LOAD ACTIVE SUB DESCRIPTION atd.service loaded active running Deferred execution scheduler blk-availability.service loaded active exited Availability of block devices cloud-config.service loaded active exited Apply the settings specified in cloud-config cloud-final.service loaded active exited Execute cloud user/final scripts cloud-init-local.service loaded active exited Initial cloud-init job (pre-networking) cloud-init.service loaded active exited Initial cloud-init job (metadata service crawler) console-setup.service loaded active exited Set console font and keymap cron.service loaded active running Regular background program processing daemon crowdsec-firewall-bouncer.service loaded active running The firewall bouncer for CrowdSec crowdsec.service loaded active running Crowdsec agent dbus.service loaded active running D-Bus System Message Bus getty@tty1.service loaded active running Getty on tty1 ifupdown-pre.service loaded active exited Helper to synchronize boot up for ifupdown keyboard-setup.service loaded active exited Set the console keyboard layout kmod-static-nodes.service loaded active exited Create List of Static Device Nodes lvm2-monitor.service loaded active exited Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling mariadb.service loaded active running MariaDB 10.11.3 database server networking.service loaded active exited Raise network interfaces nginx.service loaded active running A high performance web server and a reverse proxy server qemu-guest-agent.service loaded active running QEMU Guest Agent resolvconf.service loaded active exited Nameserver information manager semaphore.service loaded active running Ansible Semaphore serial-getty@ttyS0.service loaded active running Serial Getty on ttyS0 ssh.service loaded active running OpenBSD Secure Shell server systemd-binfmt.service loaded active exited Set Up Additional Binary Formats systemd-fsck@dev-disk-by\x2duuid-1E22\x2dDC00.service loaded active exited File System Check on /dev/disk/by-uuid/1E22-DC00 systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage systemd-journald.service loaded active running Journal Service systemd-logind.service loaded active running User Login Management systemd-modules-load.service loaded active exited Load Kernel Modules systemd-random-seed.service loaded active exited Load/Save Random Seed systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems systemd-sysctl.service loaded active exited Apply Kernel Variables systemd-sysusers.service loaded active exited Create System Users systemd-timesyncd.service loaded active running Network Time Synchronization systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories systemd-udev-trigger.service loaded active exited Coldplug All udev Devices systemd-udevd.service loaded active running Rule-based Manager for Device Events and Files systemd-update-utmp.service loaded active exited Record System Boot/Shutdown in UTMP systemd-user-sessions.service loaded active exited Permit User Sessions ufw.service loaded active exited Uncomplicated firewall user-runtime-dir@0.service loaded active exited User Runtime Directory /run/user/0 user@0.service loaded active running User Manager for UID 0 LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 44 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'.
  • Youtube in Grav

    Grav
    1
    0 Stimmen
    1 Beiträge
    503 Aufrufe
    Niemand hat geantwortet