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

  • 0 Stimmen
    6 Beiträge
    2k Aufrufe
    I

    Vielen lieben Dank Nico!
    Jetzt läuft vaultwarden.

  • EndeavourOS - ein Test

    Linux
    12
    0 Stimmen
    12 Beiträge
    171 Aufrufe
    FrankMF

    Ich möchte aus Fairness Gründen hier festhalten, das die Probleme mit dem Standby in Endeavour vermutlich kein Problem der Distrubution sind.

    Bitte dazu folgenden Beitrag von mir lesen.
    https://linux-nerds.org/topic/1397/debian-bookworm-12-test/3

  • Portainer - Python3.10

    Linux
    1
    0 Stimmen
    1 Beiträge
    53 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    4 Beiträge
    284 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.

  • 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

  • DNS testen

    Linux
    1
    0 Stimmen
    1 Beiträge
    94 Aufrufe
    Niemand hat geantwortet
  • SCP mit IPv6 nutzen

    Linux
    1
    0 Stimmen
    1 Beiträge
    203 Aufrufe
    Niemand hat geantwortet
  • Installation von Grav & NGinx & PHP7.2

    Angeheftet Verschoben Grav
    2
    0 Stimmen
    2 Beiträge
    1k Aufrufe
    FrankMF

    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.