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

  • Intel ARC A580

    Linux
    4
    0 Stimmen
    4 Beiträge
    242 Aufrufe
    FrankMF

    Zwei Monitore ausprobiert, einen 4K und einen Full-HD (HDMI). Lief einwandfrei, auch gemeinsam.

  • Restic v0.16.0 released

    Restic
    1
    0 Stimmen
    1 Beiträge
    93 Aufrufe
    Niemand hat geantwortet
  • ZFS - One Disk Pool -> Mirror Pool

    Linux
    1
    0 Stimmen
    1 Beiträge
    142 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    3 Beiträge
    1k Aufrufe
    M

    @frankm

    Habe neulich auch einen meiner rockpro64 neu mit Debian 11 installiert, und dabei auch die festplatte (NVMe eigentlich) verschlüsselt.

    War mir erst unsicher das ich dann immer eine serielle Console brauch bei reboot. Man kann aber auch dropbear (SSH server) in die initram integrieren und dann während das booten den Server erreichen und die Passphrase für das Laufwerk eingeben.

    Diese 2 links waren hilfreich.

    https://salsa.debian.org/debian/dropbear/blob/debian/2018.76-5/debian/README.initramfs
    https://unix.stackexchange.com/questions/411945/luks-ssh-unlock-strange-behaviour-invalid-authorized-keys-file

    M

  • WLan auf der Konsole einrichten

    Angeheftet Linux
    3
    0 Stimmen
    3 Beiträge
    530 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.

  • 0 Stimmen
    4 Beiträge
    533 Aufrufe
    FrankMF

    Das Setup heute mal getestet um zu sehen, ob das auch so funktioniert.

    LAN an meine Fritzbox (DHCP) an eth1.100 mein Notebook an eth1.200 meine PS4

    Und dann mal gemütlich eine Runde MW gezockt. Läuft alles einwandfrei 🙂

  • IPv6 und Subnetze

    Linux
    1
    0 Stimmen
    1 Beiträge
    200 Aufrufe
    Niemand hat geantwortet
  • Liste von Linuxbefehlen

    Angeheftet Linux
    3
    0 Stimmen
    3 Beiträge
    642 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'.