Ankündigung

Einklappen
Keine Ankündigung bisher.

Erster Start nach Neuinstallation geht schief

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Erster Start nach Neuinstallation geht schief

    Hi Wolfram wvhn

    Ich habe zwei identische Raspberri PI CM5 Systeme angeschafft. Eins wird mein Produktivsystem, das andere Backup.
    Das erste habe ich erfolgreich und ohne jegliche Probleme mit SHNG 1.11 und der smartVISU 3.5.0 installiert.
    Auf Raspberry OS Bookworm.
    Jetzt habe ich das zweite System nachziehen wollen. SHNG läuft. SmartVISU habe ich installiert wie schon 100 mal zuvor, genau nach Komplettanleitung.

    Bei der Installation gab es keine Auffälligkeiten, aber beim ersten Aufruf kommt nur das, egal in welchem Browser:

    Code:
    <?php
    /**
    * -----------------------------------------------------------------------------
    * @package smartVISU
    * @author Martin Gleiß
    * @copyright 2012 - 2024
    * @license GPL [http://www.gnu.de]
    * -----------------------------------------------------------------------------
    */
    
    // rediret to index.php if requested as default document (prevents issue of double loading same page by different URL)
    if (basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) != basename($_SERVER['SCRIPT_NAME'])) {
    header('Location: index.php?' . parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY) , 301);
    exit;
    }
    
    // get config-variables
    require_once 'lib/includes.php';
    
    // init parameters
    $request = array_merge($_GET, $_POST);
    
    // override configured pages if a corresponding request parameter is passed
    $actual_pages = (isset($request['pages']) && $request['pages'] != '') ? $request['pages'] : config_pages;
    
    // if page is not in $request use default index page defined in defaults.ini
    if (!isset($request['page']) || $request['page'] == '')
    $request['page'] = config_index;
    
    // Caching
    $config_cache = ($request ['page'] == 'assistant') ? false : config_cache;
    
    header('Cache-Control: must-revalidate');
    require_once 'lib/pagecache.php';
    $cache = new Pagecache(const_path . 'temp/pagecache/' . config_cachefolder . '/' . $actual_pages . '/' . $request['page'] . '.html', $config_cache);
    
    if (is_file(const_path."pages/".$actual_pages."/".$request['page'].".html")
    or is_file(const_path."apps/".$request['page'].".html")
    or is_file(const_path."pages/smarthome/".$request['page'].".html")
    or is_file(const_path."pages/base/".$request['page'].".html")
    or is_file(const_path."dropins/".$request['page'].".html")
    )
    {
    // init template engine
    require_once const_path.'vendor/autoload.php';
    
    //----------------------------------------------------------
    // create search path for all templates
    //----------------------------------------------------------
    $loader = new \Twig\Loader\FilesystemLoader(const_path.'apps');
    
    if (is_dir(const_path.'pages/'.$actual_pages))
    $loader->addPath(const_path.'pages/'.$actual_pages);
    
    if (\dirname($request['page']) != '.' && is_dir(const_path.'pages/'.$actual_pages.'/'.\dirname($request['page'])))
    $loader->addPath(const_path.'pages/'.$actual_pages.'/'.\dirname($request['page']));
    
    // add smarthome dir if it is not directly chosen - allows combination of custom pages with auto-generated pages from smarthomeNG
    if (substr(config_driver, 0, 9) == 'smarthome' and $actual_pages != 'smarthome' and is_dir(const_path."pages/smarthome"))
    $loader->addPath(const_path.'pages/smarthome');
    
    // make sure SV doesn't load stuff from dropins unless pages are configured
    if ($actual_pages != '') {
    $loader->addPath(const_path.'dropins');
    }
    $loader->addPath(const_path.'pages/base');
    
    //----------------------------------------------------------
    // create widgets path in namespace @widgets
    //----------------------------------------------------------
    $loader->addPath(const_path.'widgets', 'widgets');
    $loader->addPath(const_path.'dropins/widgets', 'widgets');
    $loader->addPath(const_path.'dropins/shwidgets', 'widgets');
    if (is_dir(const_path.'pages/'.$actual_pages.'/widgets'))
    $loader->addPath(const_path.'pages/'.$actual_pages.'/widgets', 'widgets');
    
    //----------------------------------------------------------
    // create icons path in namespace @icons
    //----------------------------------------------------------
    $loader->addPath(const_path.'icons/ws', 'icons');
    $loader->addPath(const_path.'dropins/icons/ws', 'icons');
    
    // init environment
    $twig = new \Twig\Environment($loader);
    $twig->addExtension(new \Twig\Extension\StringLoaderExtension());
    
    if (\defined('config_debug')) {
    if (config_debug) {
    $twig->enableDebug();
    $twig->addExtension(new \Twig\Extension\DebugExtension());
    }
    }
    
    if ($config_cache)
    $twig->setCache(const_path.'temp/twigcache');
    
    foreach ($request as $key => $val)
    {
    if ($key == "page")
    $val = basename(str_replace('.', '_', $val));
    
    $twig->addGlobal($key, $val);
    }
    
    $twig->addGlobal('icon1', config_design_icon1);
    $twig->addGlobal('icon0', config_design_icon0);
    
    
    foreach (get_defined_constants() as $key => $val)
    {
    if (substr($key, 0, 6) == 'config')
    $twig->addGlobal($key, $val);
    }
    
    // attention: global value for config_pages in php can be different from value with same name in Twig if the "pages" parameter is set
    $twig->addGlobal('config_pages', $actual_pages);
    $twig->addGlobal('configured_pages', config_pages);
    $twig->addGlobal('pagepath', \dirname($request['page']));
    $twig->addGlobal('const_path', const_path);
    $twig->addGlobal('mbstring_available', function_exists('mb_get_info'));
    
    $twig->addFilter( new \Twig\TwigFilter('_', 'twig_concat'));
    $twig->addFilter( new \Twig\TwigFilter('bit', 'twig_bit'));
    $twig->addFilter( new \Twig\TwigFilter('substr', 'twig_substr'));
    $twig->addFilter( new \Twig\TwigFilter('smartdate', 'twig_smartdate'));
    $twig->addFilter( new \Twig\TwigFilter('deficon', 'twig_deficon', array('needs_environment' => true)));
    $twig->addFilter( new \Twig\TwigFilter('md5', 'twig_md5'));
    $twig->addFilter( new \Twig\TwigFilter('preg_replace', 'twig_preg_replace'));
    
    $twig->addFunction( new \Twig\TwigFunction('uid', 'twig_uid'));
    $twig->addFunction( new \Twig\TwigFunction('once', 'twig_once'));
    $twig->addFunction( new \Twig\TwigFunction('isfile', 'twig_isfile'));
    $twig->addFunction( new \Twig\TwigFunction('isdir', 'twig_isdir'));
    $twig->addFunction( new \Twig\TwigFunction('dir', 'twig_dir'));
    $twig->addFunction( new \Twig\TwigFunction('docu', 'twig_docu'));
    $twig->addFunction( new \Twig\TwigFunction('configmeta', 'twig_configmeta'));
    $twig->addFunction( new \Twig\TwigFunction('lang', 'twig_lang'));
    $twig->addFunction( new \Twig\TwigFunction('read_config', 'twig_read_config'));
    $twig->addFunction( new \Twig\TwigFunction('timezones', 'twig_timezones'));
    $twig->addFunction( new \Twig\TwigFunction('implode', 'twig_implode', array('is_safe' => array('html'))));
    $twig->addFunction( new \Twig\TwigFunction('items', 'twig_items'));
    $twig->addFunction( new \Twig\TwigFunction('asset_exists', 'twig_asset_exists'));
    $twig->addFunction( new \Twig\TwigFunction('localize_svg', 'twig_localize_svg'));
    
    // init lexer comments
    $lexer = new \Twig\Lexer($twig, array('tag_comment' => array('/**', '*/')));
    $twig->setLexer($lexer);
    
    // load template
    try
    {
    $template = $twig->loadTemplate($request['page'].'.html');
    $content = $template->render(array());
    
    if ($request['page'] == "manifest")
    {
    header('Content-Type: application/manifest+json');
    die($content);
    }
    
    // write to cache and output
    $cache->write($content);
    }
    catch (Exception $e)
    {
    // header("HTTP/1.0 602 smartVISU Template Error");
    
    echo "<pre>\n";
    echo str_repeat(" ", 71)."smartVISU\n";
    echo str_repeat(" ", 60).date('H:i, d.m').", v".config_version_full."\n";
    echo str_repeat("-", 80)."\n\n";
    echo "Error occurred in twig-template engine!\n\n";
    echo "error: <b>".$e->getRawMessage()."</b>\n";
    echo "file: ".$e->getTemplateFile()."\n";
    echo "line: ".$e->getTemplateLine()."\n\n";
    echo str_repeat("-", 80)."\n\n";
    echo "\n</pre>";
    }
    }
    else
    {
    header("HTTP/1.0 404 Not Found");
    
    echo "<pre>\n";
    echo str_repeat(" ", 71)."smartVISU\n";
    echo str_repeat(" ", 60).date('H:i, d.m').", v".config_version_full."\n";
    echo str_repeat("-", 80)."\n\n";
    echo "Error loading Page '<b>".$request['page']."</b>' !\n\n";
    echo "Check configuration page for correct pages / project configuration\n";
    echo "or try the <a href='index.php'>index</a> page!\n\n";
    echo str_repeat("-", 80)."\n\n";
    echo "\n</pre>";
    }
    ?>​
    Das hatte ich noch nie.
    In der Komplettanleitung steht seit neustem ein Hinweis zu "Problemen mit PHP". Habe ich mal ausgeführt, neu gestartet, aber keine Änderung.
    Ich habe das smartVISU Verzeichnis auch schon komplett gelöscht und alles nochmal gemacht. Keine Veränderung.
    Das kann eigentlich nur ne doofe Kleinigkeit sein.

    Irgendeine Idee?

    Gruß und danke im Voraus

    Martin

    #2
    Moin Martin,

    es sieht danach aus, dass php nicht läuft. Deswegen liefert der Webserver die index.php als Text an den Browser, anstatt sie als Skript auszuführen.

    Welchen Webserver verwendest Du?

    Gruß
    Wolfram

    Kommentar


      #3
      Den Apache.

      Code:
      ● apache2.service - The Apache HTTP Server
           Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled)
           Active: active (running) since Mon 2025-04-28 21:56:54 CEST; 1h 40min ago
             Docs: https://httpd.apache.org/docs/2.4/
          Process: 721 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
         Main PID: 764 (apache2)
            Tasks: 55 (limit: 9585)
              CPU: 109ms
           CGroup: /system.slice/apache2.service
                   ├─764 /usr/sbin/apache2 -k start
                   ├─765 /usr/sbin/apache2 -k start
                   └─766 /usr/sbin/apache2 -k start
      
      Apr 28 21:56:54 CM52 systemd[1]: Starting apache2.service - The Apache HTTP Server...
      Apr 28 21:56:54 CM52 apachectl[763]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 12>
      Apr 28 21:56:54 CM52 systemd[1]: Started apache2.service - The Apache HTTP Server.
      php läuft auch, laut ps:

      Code:
      root 655 1 0 21:56 ? 00:00:00 php-fpm: master process (/etc/php/8.2/fpm/php-fpm.conf)
      www-data 683 655 0 21:56 ? 00:00:00 php-fpm: pool www
      www-data 684 655 0 21:56 ? 00:00:00 php-fpm: pool www
      Das sieht auf dem Referenzsystem, das funktioniert, genauso aus.
      Zuletzt geändert von Sipple; 29.04.2025, 07:32.

      Kommentar


        #4
        PHP muss auch im Webserver laufen. Die entsprechenden Module müssen aktiviert sein. In /etc/apache2/mods-enabled sollte eine Konfiggurationsdatei für php vorhanden bzw. als Symlink verknüpft sein (php8.2.conf oder etwas entsprechendes mit php-fpm).

        Da ich bisher in Apache nicht mit php-fpm gearbeitet habe, kann ich Dir leider mit der Konfiguration von fpm nicht helfen. Vielleicht hilft das hier weiter.

        Ohne fpm sind bei mir folgende PHP-Pakete installiert:
        Code:
        $ dpkg -l|grep php
        ii  libapache2-mod-php8.2            8.2.7-1~deb12u1+rpi1             armhf        server-side, HTML-embedded scripting language (Apache 2 module)
        ii  libawl-php                       0.64-1                           all          Andrew's Web Libraries - PHP Utility Libraries
        ii  php                              2:8.2+93                         all          server-side, HTML-embedded scripting language (default)
        ii  php-common                       2:93                             all          Common files for PHP packages
        ii  php-curl                         2:8.2+93                         all          CURL module for PHP [default]
        ii  php-json                         2:8.2+93                         all          JSON module for PHP [default]
        ii  php-mbstring                     2:8.2+93                         all          MBSTRING module for PHP [default]
        ii  php-xml                          2:8.2+93                         all          DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]
        ii  php8.2                           8.2.7-1~deb12u1+rpi1             all          server-side, HTML-embedded scripting language (metapackage)
        ii  php8.2-cli                       8.2.7-1~deb12u1+rpi1             armhf        command-line interpreter for the PHP scripting language
        ii  php8.2-common                    8.2.7-1~deb12u1+rpi1             armhf        documentation, examples and common module for PHP
        ii  php8.2-curl                      8.2.7-1~deb12u1+rpi1             armhf        CURL module for PHP
        ii  php8.2-mbstring                  8.2.7-1~deb12u1+rpi1             armhf        MBSTRING module for PHP
        ii  php8.2-opcache                   8.2.7-1~deb12u1+rpi1             armhf        Zend OpCache module for PHP
        ii  php8.2-readline                  8.2.7-1~deb12u1+rpi1             armhf        readline module for PHP
        ii  php8.2-xml                       8.2.7-1~deb12u1+rpi1             armhf        DOM, SimpleXML, XML, and XSL module for PHP
        Welche Module davon aktiviert sind, sieht man in /etc/php/8.2/apache2/conf.d

        Gruß
        Wolfram

        EDIT: zum Testen ohne smartVISU kannst Du unter /var/www/html die Datei info.php anlegen
        Code:
        <?php
        phpinfo();
        ​
        und die dann im Browser aufrufen mit "<DeineIP>/info.php".
        Zuletzt geändert von wvhn; 29.04.2025, 09:34.

        Kommentar


          #5
          Ok, danke, ich probiere die Tage mal rum.

          Kommentar


            #6
            So funktioniert wieder.
            Nur was es ganz genau war, kann ich nicht sagen.
            a2enmod etc. haben nicht geholfen. Auch keine Neustarts, Restarts, Config Dateien. Alles identisch zum Referenzsystem.
            Dann habe ich alle Paketinstallationsbefehle von der Komplettinstallation für die Visu nochmal laufen lassen. Logischerweise kam da nur "ist schon installiert", hat also ebenfalls nichts gebracht. Letztlich habe ich einen ähnlichen apt-get install ....... von einer Seite aus dem Netz mit empfohlenen Paketen für PHP laufen lassen. Da waren auch alle dabei, die auch in der Komplettanleitung stehen und zusätzlich noch ein paar weitere. Irgendeines davon, oder ein damit verbundener Schritt bei dessen Installation, führte dann zum Erfolg.
            Warum das auf dem einen System von Anfang an klappte, auf dem identischen, was ich nur zwei Wochen später installiert habe, aber nicht, weiß der Geier.
            Zuletzt geändert von Sipple; 30.04.2025, 11:59.

            Kommentar

            Lädt...
            X