Skip to content

ReactPHP auf einem ROCKPro64 testen

Linux
  • Meine Inspiration für diesen Beitrag
    https://www.youtube.com/watch?time_continue=2&v=XoDBtz5P8q8&feature=emb_logo

    Hardware

    ROCKPro64

    Betriebssystem

    Debian Buster 10 Minimal von Kamil

    root@rockpro64:/var/www/html# uname -a
    Linux rockpro64 4.4.197-1236-rockchip-ayufan-g30faab37e339 #1 SMP Tue Oct 22 11:35:10 UTC 2019 aarch64 GNU/Linux
    

    Installation PHP

    https://forum.frank-mankel.org/topic/730/php-installation

    Installation NGINX (Mainline Version)

    apt install curl gnupg2 ca-certificates lsb-release
    echo "deb http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx"     | sudo tee /etc/apt/sources.list.d/nginx.list
    curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
    sudo apt-key fingerprint ABF5BD827BD9BF62
    apt update && apt install nginx
    

    Testen

    root@rockpro64:/var/www/html# nginx -v
    nginx version: nginx/1.14.2
    

    Jetzt wird es wieder interessant.

    root@rockpro64:/var/www/html# ls -lha /usr/share/nginx/html/
    total 12K
    drwxr-xr-x 2 root root 4.0K Dec 31 09:14 .
    drwxr-xr-x 4 root root 4.0K Dec 31 09:10 ..
    -rw-r--r-- 1 root root  646 Dec 31 09:14 index.php
    

    Aber, dieser Ordner zieht nicht 😞

    Dieser Ordner zieht.

    root@rockpro64:/var/www/html# ls
    index.php
    

    Immer wieder interessant, wie das je nach Plattform sich ändert. Der Pfad wird bei dieser Installation hier festgelegt.

    /etc/nginx/sites-enabled/default
    

    Wir halten fest, dieser wird gebraucht.

    /var/www/html
    

    Für unseren Testserver sollte das erst mal egal sein.

    React Voraussetzungen

    Composer

    Für reactPHP brauchen wir als erstes den Composer Was ist das? Composer ist ein Paketmanager für PHP, ok nicht ganz korrekt.

    Composer is not a package manager in the same sense as Yum or Apt are. Yes, it deals with "packages" or libraries, but it manages them on a per-project basis, installing them in a directory (e.g. vendor) inside your project. By default it does not install anything globally. Thus, it is a dependency manager. It does however support a "global" project for convenience via the global command.

    Composer Installation

    apt install curl php-cli php-mbstring git unzip
    curl -sS https://getcomposer.org/installer -o composer-setup.php
    

    Aktuellen Hash von der Downloadseite besorgen!

    HASH=48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5
    

    Hash checken!

    php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    

    Ausgabe

    Installer verified
    

    Composer global installieren!!!

    php composer-setup.php --install-dir=/usr/local/bin --filename=composer
    

    Ausgabe:

    All settings correct for using Composer
    Downloading...
    
    Composer (version 1.9.1) successfully installed to: /usr/local/bin/composer
    Use it: php /usr/local/bin/composer
    

    Ok, testen

    root@rockpro64:~# composer
    Do not run Composer as root/super user! See https://getcomposer.org/root for details
       ______
      / ____/___  ____ ___  ____  ____  ________  _____
     / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
    / /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
    \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                        /_/
    Composer version 1.9.1 2019-11-01 17:20:17
    
    Usage:
      command [options] [arguments]
    
    Options:
      -h, --help                     Display this help message
      -q, --quiet                    Do not output any message
      -V, --version                  Display this application version
          --ansi                     Force ANSI output
          --no-ansi                  Disable ANSI output
      -n, --no-interaction           Do not ask any interactive question
          --profile                  Display timing and memory usage information
          --no-plugins               Whether to disable plugins.
      -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
          --no-cache                 Prevent use of the cache
      -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
    [...gekürzt...]
    

    ReactPHP

    Dann mal das erste ReactPHP Testprojekt installieren 🙂 Laut der ReactPHP Webseite brauchen wir für einen HTTP Server, das Paket http, das man wie folgt installiert.

    Wir wechseln in unser Testverzeichnis /var/www/html

    composer require react/http:^0.8.5
    

    Ausgabe:

    root@rockpro64:/var/www/html# composer require react/http:^0.8.5
    Do not run Composer as root/super user! See https://getcomposer.org/root for details
    
    ./composer.json has been created
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Package operations: 12 installs, 0 updates, 0 removals
      - Installing react/promise (v2.7.1): Downloading (100%)         
      - Installing evenement/evenement (v3.0.1): Downloading (100%)         
      - Installing react/event-loop (v1.1.0): Downloading (100%)         
      - Installing react/stream (v1.1.0): Downloading (100%)         
      - Installing react/promise-stream (v1.2.0): Downloading (100%)         
      - Installing react/promise-timer (v1.5.1): Downloading (100%)         
      - Installing react/cache (v1.0.0): Downloading (100%)         
      - Installing react/dns (v1.2.0): Downloading (100%)         
      - Installing react/socket (v1.3.0): Downloading (100%)         
      - Installing psr/http-message (1.0.1): Downloading (100%)         
      - Installing ringcentral/psr7 (1.2.2): Downloading (100%)         
      - Installing react/http (v0.8.5): Downloading (100%)         
    react/event-loop suggests installing ext-event (~1.0 for ExtEventLoop)
    react/event-loop suggests installing ext-uv (* for ExtUvLoop)
    Writing lock file
    Generating autoload files
    

    Ja, ich weiß, das macht man nicht als ROOT 😊

    chown -R www-data:www-data /var/www/html
    

    Wir bearbeiten das File index.php, so mal als schnellen Test. Dazu nehmen wir vom Christian Lück, das Hello World Beispiel, ein Klassiker 🙂

    <?php
    use Psr\Http\Message\ServerRequestInterface;
    use React\EventLoop\Factory;
    use React\Http\Response;
    use React\Http\Server;
    require __DIR__ . '/../vendor/autoload.php';
    $loop = Factory::create();
    $server = new Server(function (ServerRequestInterface $request) {
        return new Response(
            200,
            array(
                'Content-Type' => 'text/plain'
            ),
            "Hello world\n"
        );
    });
    $socket = new \React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0', $loop);
    $server->listen($socket);
    echo 'Listening on ' . str_replace('tcp:', 'http:', $socket->getAddress()) . PHP_EOL;
    $loop->run();
    

    Quelle: https://github.com/reactphp/http/blob/master/examples/01-hello-world.php

    Diese Dateien müssen gestartet werden, also so wie das

    ./nodebb start
    

    Gut zu wissen. Christian macht das im Video mit

    php index.php
    

    Erster Versuch

    root@rockpro64:/var/www/html# php index.php 
    PHP Warning:  require(/var/www/html/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/index.php on line 6
    PHP Fatal error:  require(): Failed opening required '/var/www/html/../vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/html/index.php on line 6
    

    Das schaut nach falschem Pfad aus.

    /var/www/html/../vendor/autoload.php
    

    Dann ändere ich den mal ab

    require __DIR__ . '/vendor/autoload.php';
    

    Nächster Versuch

    root@rockpro64:/var/www/html# php index.php 
    Listening on http://0.0.0.0:33100
    

    Ok, der Server läuft, aber nur lokal auf meinem ROCKPro64, etwas blöd zum Testen. Grübel, wir ändern mal eben die Zeile.

     $socket = new \React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0', $loop);
    

    in

    $socket = new \React\Socket\Server(isset($argv[1]) ? $argv[1] : '192.168.3.7:0', $loop);
    

    Ich weiß, nicht so schön. Wenn die IP-Adresse des RockPro64 sich ändert usw. Aber für einen kurzen Test muss das mal eben reichen 😁

    Nächster Versuch

    root@rockpro64:/var/www/html# php index.php 
    Listening on http://192.168.3.7:44815
    

    Gut, damit kann man arbeiten.

    b08824fe-d87b-4be2-a89c-66d647b9d58d-image.png

  • Proxmox 8.2 released

    Proxmox
    1
    0 Stimmen
    1 Beiträge
    42 Aufrufe
    Niemand hat geantwortet
  • KDE Plasma 6 - Beta 2

    Linux
    2
    0 Stimmen
    2 Beiträge
    139 Aufrufe
    FrankMF

    Leider hat die Realität mich etwas vom Testen neuer Software abgehalten, aber jetzt geht es langsam wieder los. Den Start macht KDE Plasma 6 - Beta 2. Auch wenn ich schon brennend auf die RC1 warte, die lässt aber noch auf sich warten...

    https://pointieststick.com/category/this-week-in-kde/

    Ok, also die Beta 2 auf meinen Stick und ab damit in mein Testsystem. Einmal starten, kurz danach taucht der KDE Neon Desktop auf.

    20240110_201838.jpg

    20240110_201852.jpg

    Und klick, wird die Installation gestartet. Danach begrüßt uns dieses Fenster. Ich weiß nicht, warum diese Information nicht automatisch ermittelt wird - nervig.

    20240110_201924.jpg

    Der Rest der Installation lief einwandfrei, ich habe aber keine besondere Installation vorgenommen. Ganze NVMe plattgemacht und alles drauf. Nichts verschlüsselt usw. Eine Installation, die ich so für meinen Haupt-PC nicht machen würde.

    Eine Kleinigkeit ist mir noch aufgefallen. Der Calamares Installer der benutzt wird, hat bei mir keine Sonderzeichen akzeptiert. Ich hoffe das wird bis zum Release gefixt.

    Hier noch kurz das Testsystem

    Screenshot_20240111_210201.png

    Ich nutze ausschließlich Wayland, das läuft einfach wesentlich besser. Aber, ich weiß da draußen gibt es viele die das nicht mögen. Das schöne an Linux - ihr habt die freie Wahl.

    Was war mir negativ aufgefallen? Installer - keine automatische Standortbestimmung Installer - nimmt keine Sonderzeichen für das PW an Login Window - nach Eingabe PW wird die Taste RETURN nicht akzeptiert. Muss ich mit der Maus anklicken. Skalierung auf meinem Monitor nicht optimal - Schrift unscharf Was ist mir positiv aufgefallen? Ich nutze einen 4K Monitor zum Testen. Die Skalierung war automatisch auf 175%. Eine fast perfekte Wahl, wenn da nicht die unscharfe Schrift wäre. Ich habe das auf 150% gestellt, danach war es deutlich besser. Updates kann man sich über das grafische Frontend holen Standby-Modus ging Und einen nervigen FF Bug konnte ich nicht nachstellen. Auf meinem aktuellen System, KDE Plasma 5, flackert der Bildschirm gelegentlich, wenn ich in der Taskleiste durch die geöffneten FF Fenster scrolle. Bei Plasma 6 konnte ich das bis jetzt noch nicht feststellen. Fazit

    Sieht gut aus, der Release von KDE Plasma 6 wird gut. Ich freu mich drauf. Und diesen komischen Updatevorgang den KDE Neon da benutzt, diesen M$ Style, den könnt ihr direkt wieder in die Mülltonne kloppen. Das möchte ich bei Linux nicht sehen.

    Screenshot_20240111_214255.png

  • Pycharm - Umzug auf neuen Rechner

    Linux
    1
    0 Stimmen
    1 Beiträge
    54 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    4 Beiträge
    286 Aufrufe
    FrankMF

    Es geht weiter, der erste ☕ und ich bin mit der Lösung nicht so richtig zufrieden, also suchen.

    Als erstes habe ich heute Morgen ein frisches SD-Karten Image mit Docker von FreindlyWrt genommen und auf meinem Test NanoPi R5S installiert. Dort mal die Config angeschaut um zu sehen, ob der Eintrag standardmäßig gesetzt ist. Doch dort taucht dann einmal eine ganz ander Config auf 🙄

    # The following settings require a restart of docker to take full effect, A reload will only have partial or no effect: # bip # blocked_interfaces # extra_iptables_args # device config globals 'globals' # option alt_config_file '/etc/docker/daemon.json' option enable '1' option data_root '/mnt/nvme_part2/docker' option log_level 'warn' option iptables '1' #list hosts 'unix:///var/run/docker.sock' # option bip '172.18.0.1/24' # option fixed_cidr '172.17.0.0/16' # option fixed_cidr_v6 'fc00:1::/80' # option ipv6 '1' # option ip '::ffff:0.0.0.0' # list dns '172.17.0.1' # list registry_mirrors 'https://<my-docker-mirror-host>' list registry_mirrors 'https://hub.docker.com' option remote_endpoint '0' # option bridge 'br-container' # Docker ignores fw3 rules and by default all external source IPs are allowed to connect to the Docker host. # See https://docs.docker.com/network/iptables/ for more details. # firewall config changes are only additive i.e firewall will need to be restarted first to clear old changes, # then docker restarted to load in new changes. config firewall 'firewall' option device 'docker0' list blocked_interfaces 'wan' option extra_iptables_args '--match conntrack ! --ctstate RELATED,ESTABLISHED' # allow outbound connections

    Das interessiert uns jetzt

    list blocked_interfaces 'wan' option extra_iptables_args '--match conntrack ! --ctstate RELATED,ESTABLISHED' # allow outbound connections

    Wenn ich das jetzt alles richtig verstehe, muss WAN geblockt sein, weil sonst der Docker Host offen im Netz steht (Hierbei bin ich mir nicht 100% sicher)
    Die zweite Zeile ist eine iptables Regel, die es den Containern dann ermöglicht das Internet zu erreichen.

    Das habe ich jetzt so eingestellt und getestet.

    root@b9ffae24913a:/# ping 1.1.1.1 PING 1.1.1.1 (1.1.1.1): 56 data bytes 64 bytes from 1.1.1.1: icmp_seq=0 ttl=57 time=17.151 ms 64 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=16.553 ms 64 bytes from 1.1.1.1: icmp_seq=2 ttl=57 time=20.630 ms 64 bytes from 1.1.1.1: icmp_seq=3 ttl=57 time=13.948 ms ^C--- 1.1.1.1 ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max/stddev = 13.948/17.071/20.630/2.382 ms root@b9ffae24913a:/# ping google.de PING google.de (142.250.185.195): 56 data bytes 64 bytes from 142.250.185.195: icmp_seq=0 ttl=58 time=23.797 ms 64 bytes from 142.250.185.195: icmp_seq=1 ttl=58 time=16.953 ms 64 bytes from 142.250.185.195: icmp_seq=2 ttl=58 time=19.441 ms ^C--- google.de ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max/stddev = 16.953/20.064/23.797/2.829 ms

    Ich hoffe mal das ich diese Thema jetzt zu den Akten legen kann.

    Wenn was falsch ist, bitte hier kommentieren, damit ich das ändern kann.

  • Storage Box für den REST-Server

    Restic
    1
    0 Stimmen
    1 Beiträge
    123 Aufrufe
    Niemand hat geantwortet
  • WLan auf der Konsole einrichten

    Angeheftet Linux
    3
    0 Stimmen
    3 Beiträge
    526 Aufrufe
    FrankMF

    Ich kann im Manjaro keine WPA3 Sicherheit auswählen, dann bekomme ich keine Verbindung. Es geht nur WPA2 Personal. Gegenstelle ist eine FRITZ!Box 6591 Cable.

    2021-11-28_16-37.png

    In der Fritzbox sieht das so aus

    50d23aa8-5f67-485e-a994-244ef4f6a270-image.png

    Das kam als Fehlermeldung

    Nov 28 11:03:07 frank-pc wpa_supplicant[700]: wlan0: Trying to associate with SSID 'FRITZ!Box 6591 Cable AK' Nov 28 11:03:07 frank-pc wpa_supplicant[700]: wlan0: WPA: Failed to select authenticated key management type Nov 28 11:03:07 frank-pc wpa_supplicant[700]: wlan0: WPA: Failed to set WPA key management and encryption suites

    Ich denke, der Treiber unterstützt das nicht.

  • 1 Stimmen
    13 Beiträge
    1k Aufrufe
    FrankMF

    Ich möchte das dann hier zum Abschluss bringen, das NAS ist heute zusammengebaut worden. Hier zwei Fotos.

    IMG_20200425_102156_ergebnis.jpg

    IMG_20200425_102206_ergebnis.jpg

  • DNS testen

    Linux
    1
    0 Stimmen
    1 Beiträge
    94 Aufrufe
    Niemand hat geantwortet