iAPLR

            4U (especially for You)

### USE SERVER OS TO INSTALL WEB APP.
### (stages I-II of: install use daemons troubleshoot)

## PREREQUISITES

# VirtualBox:

  Name: BioServer
  Type: Linux
  Version: Ubuntu (64-bit)
  Memory size: 2048 MB
  Hard disk: Use existing, BioServer-16GB.vdi
  Network: NAT

  Advanced: Port Fowarding 80 to 8080 (Host)
                           22 to 2222 (Host)
            Host  IP: 127.0.0.1
            Guest IP: 10.0.2.15


# Putty

Session

  Host name: 127.0.0.1  Port: 2222
  Connection type: SSH
  Saved Sessions: BioServer

Window Appearance:

  Font: Lucida Console, 16

Connection -> SSH -> X11

  [v] Enable X11 forwarding

Session

  1. [Save]
  2. [Open]


# BioServer

login: virtu
password: virtu

  $ sudo -s
  # apt-get update
  # apt-get upgrade
  # ip a
  enp0s3  inet 10.0.2.15/24
  # systemctl status apache2
  active (running)

WWW Home is /var/www/html

Should response to:

  http://localhost:8080
  http://localhost:8080/phpinfo.php


## ISLANDS

HTML file integrates:

  +  markup (html),
  +  style (cascading styles sheet),
  +  script (javascript)
  +  server side scripting (php)

  +---------------------------------------------------------+
  | NB! if HTML contains PHP islands, such file should have |
  |     .php extension, no matter if actually this is       |
  |     a html file.                                        |
  +---------------------------------------------------------+

Problems to solve:

git clone and run PHP-calculator from:

  https://gist.github.com/jkuip/43bb6716e0e907f74b49

Run PHP-calculator from:

  https://stackoverflow.com/questions/44968757
      /only-php-code-calculator-with-clickable-buttons-as-input

Run JS-calculator from:

  https://www.mindstick.com/Articles/1530
     /design-a-simple-stylish-calculator-using-html-css-and-javascript

Do some style changes.

## NEXT AFTER HELLOWORLD

Today we rarely build from scratch. Usually we have pretty large "DONOTTOUCH" code built for us by wizard, "free-beer" gui or friendly alien. We have to mark "Under Construction" area and start our discovery. And don't cross the line.. please:)

Task: from Problem A crop template like:

                       -----
  Text: [...........] | Run |
                       -----

Mark permitted area with comments:

  <?php
  // *********** Under Construction ***********

  // your code here

  // *********** noitcurtsnoC rednU ***********
  ?>

Note: Error messages in /var/log/apache2/error.log

Result:

template.php

  <!DOCTYPE html>
  <html>
    <head>
      <title>Template</title>
      <meta charset="utf-8">
    </head>
    <body>
      <?php
        // *********** Under Construction ***********

        // If the submit button has been pressed
        if( isset($_POST['submit'])) {
            $s=$_POST['mydata'];
            require_once('/home/virtu/exercise.php');
        }

        // *********** noitcurtsnoC rednU ***********
      ?>

      <!-- Template form -->
      <form method="post" action="template.php">
          <input name="mydata" type="text" class="form-control"
              value='<?php if (!isset($s)) echo ""; else echo "$s";?>'
              style="width: 150px; display: inline" autofocus />
          <input name="submit" type="submit" value="Run"/>
      </form>
    </body>
  </html>

exercise.php

  <?php
  echo "<h1>{$s}</h1>";
  ?>

## Links.

  1. Beginners PHP: This is a complete and free PHP programming course for beginners.

    https://www.homeandlearn.co.uk/php/php.html
.
  2. Tutorials (most of them copy-paste to install)

    http://www.phpeasystep.com/

  3. Calculators.

    http://www.html.by/threads/21639-Knopochnyj-kalkuljator-na-php
    http://qaru.site/questions/545353/simple-php-calculator
    http://dwweb.ru/page/php/035_kalkulyator_na_php.html
    https://www.codeproject.com/Tips/631525/Creating-Calculator-
        using-HTML-CSS-and-JavaScript?msg=5474289
    https://www.codeproject.com/Questions/1238337/
        Php-calculator-using-number-buttons
    https://www.dreamincode.net/forums/topic/295301-how-to-make-
        complete-calculator-with-all-buttons-using-php/

  Buttons.

    https://freshdesignweb.com/css3-buttons/
