Schrijf serverstatus.php

Docent uitwerking

Geschreven door Peter van Gemert

Op 11 augustus 2023


Schrijf server-status.php

  webserver $ sudo su -
  webserver # cd /remote/nfs/website

  webserver # vi serverstatus.php
      <?php
              echo "<!DOCTYPE html>";
              
              echo "<html>";
              
              echo "<head>";
              echo "  <title>Serverstatus</title>";
              echo "  <link type="stylesheet" href="/css/serverstatus.css">";
              echo "</head>";
              
              echo "<body>";
              
              echo "<h1>Server status</h1>";
              echo "<hr>";
              
              echo "<h2>Servertijd</h2>";
              echo "<p>";
              $servertijd = shell_exec('date');
              echo "$servertijd";
              echo "</p>";
              
              echo "<h2>Uptime</h2>";
              echo "<p>";
              $uptime = shell_exec('/usr/bin/uptime');
              echo "$uptime";
              echo "</p>";
              
              echo "<h2>Running processes</h2>";
              echo "<p>";
              $runproc = shell_exec('/usr/bin/ps -ef | /usr/bin/wc -l');
              echo "$runproc";
              echo "</p>";
      ?>
  
  webserver # php serverstatus.php

Schrijf opmaak.css

  webserver # cd /remote/nfs/website
  wbeserver # mkdir css ; cd css
  
  webserver # vi serverstatus.css
      body {
          background-color: rgb(0,0,0);
          color: rgb(255,255,255);
          font-family: sans-serif;
      }
            
      h1 {
          color: rgb(255,0,0);
      }
            
      h2 {
          color: rgb(240,0,0);
          text-decoration: underline;
      }
            
      p {
          margin-left: 5%;
          font-size: 110%;
      }

Zet file mode goed

  webserver # cd /remote/nfs/website
  
  webserver # chown root:www-data serverstatus.php css/serverstatus.css
  webserver # chmod 640 serverstatus.php css/serverstatus.css