linuxkurs/15.html

523 lines
15 KiB
HTML

<!doctype html>
<html lang="de">
<meta charset="utf-8">
<title>Einführung in Linux</title>
<meta name="description" content="YALC - Yet Another Linux Course ">
<meta name="author" content="Daniel Schubert">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/league.css" id="theme">
<link rel="icon" href="img/openlogo-nd-25.png" type="img/png">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<style type="text/css">
.reveal img{ max-height: 60vh}
</style>
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section data-transition="slide" data-background="#4d7e65" data-background-transition="zoom">
<h1>LINUX</h1>
<h3>Das universelle Betriebssystem</h3>
<p>Eine Einführung - Teil 15
<p> <small>Deutsche Angestellten Akademie</small> </p>
<aside class="notes">
Frage: Fragen zur letzten Stunde?
</aside>
</section>
<section data-transition="slide" data-background="#b5533c" data-background-transition="convex"> <h3>lampp stack</h3> Linux & Apache & mysql & php</section>
<section>
<pre><code class="bash">~$ sudo apt install apache2 mysql-server phpmyadmin</code></pre>
<pre><code class="bash">~$ mysql -u root -p
MariaDB [(none)]> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'some_very_complex_password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; FLUSH PRIVILEGES;
MariaDB [(none)]> \q
</code></pre>
<ul>
<li class="fragment ">http://localhost/phpmyadmin</li>
<li class="fragment ">user: phpmyadmin</li>
<li class="fragment ">http://localhost/phpmyadmin</li>
</ul>
</section>
<section>
<h3>mysql</h3>
</section>
<section>
mysql ist eine „relationale Datenbank”
<p><blockquote> Relationale Datenbanken versuchen, die Realität in einem Datenmodell abzubilden.</blockquote>
<ul>
<li>Jede Zeile einer Tabelle ist ein Datensatz</li>
<li>Jede Zeile ( Tupel ) besteht aus <strong>Attributen</strong> ( die Spalten )</li>
<li>Über <strong>Primärschlüssel</strong> werden Beziehungen hergestellt</li>
<li>Eine Datenbank kann viele Tabellen beinhalten</li>
<li>Die Tabellen stehen in Beziehung ( Relation )</li>
</ul>
</section>
<section>
<img src="img/relationales_datenbankmodell_beispiel.jpg">
<p><small style="font-size:.4em">Quelle: http://www.datenbanken-verstehen.de/datenbank-grundlagen/datenbankmodell/relationales-datenbankmodell/</small>
</section>
<section>
<h4>Normalisierung</h4>
Aufteilung der Attribute (Spalten) in mehrere Relationen ( Tabellen ), so dass eine Form ohne Redundanzen entsteht.
</section>
<section>
<img src="img/Aufspaltung_einer_Tabelle_in_zwei_(Beispiel).svg">
</section>
<section>
<table style="font-size: .5em">
<tr>
<td>Rg Nr</td>
<td>Datum</td>
<td>Name</td>
<td>Straße</td>
<td>Ort</td>
<td>Artikel</td>
<td>Anzahl</td>
<td>Preis</td>
</tr>
<tr>
<td>143</td>
<td>01.04.2018</td>
<td>Max Müller</td>
<td>Trumstrasse 4</td>
<td>75179 Pforzheim</td>
<td>Bleistift</td>
<td>1001</td>
<td>1,00€</td>
</tr>
</table>
</section>
<section>
1. Normalform
<table style="font-size: .5em">
<tr>
<td>Rg Nr</td>
<td>Datum</td>
<td>Vor Name</td>
<td>Nach Name</td>
<td>Straße</td>
<td>Hausnr</td>
<td>PLZ</td>
<td>Ort</td>
<td>Artikel</td>
<td>Anzahl</td>
<td>Preis</td>
</tr>
<tr>
<td>143</td>
<td>01.04.2018</td>
<td>Max</td>
<td>Müller</td>
<td>Trumstrasse</td>
<td> 4</td>
<td>75179</td>
<td> Pforzheim</td>
<td>Bleistift</td>
<td>1001</td>
<td>1,00€</td>
</tr>
</table>
</section>
<section>
<table style="font-size: .5em">
<tr>
<td>Rg Nr</td>
<td>Datum</td>
<td>Vor Name</td>
<td>Nach Name</td>
<td>Straße</td>
<td>Hausnr</td>
<td>PLZ</td>
<td>Ort</td>
<td>Artikel</td>
<td>Anzahl</td>
<td>Preis</td>
</tr>
<tr>
<td>144</td>
<td>01.04.2018</td>
<td>Max</td>
<td>Müller</td>
<td>Trumstrasse</td>
<td> 4</td>
<td>75179</td>
<td> Pforzheim</td>
<td>Bleistift</td>
<td>1001</td>
<td>1,00€</td>
</tr>
<tr>
<td>145</td>
<td>01.04.2018</td>
<td>Max</td>
<td>Müller</td>
<td>Trumstrasse</td>
<td> 4</td>
<td>75179</td>
<td> Pforzheim</td>
<td>Tüte</td>
<td>1001</td>
<td>0,10€</td>
</tr>
<tr>
<td>146</td>
<td>01.04.2018</td>
<td>Max</td>
<td>Müller</td>
<td>Trumstrasse</td>
<td> 4</td>
<td>75179</td>
<td> Pforzheim</td>
<td>Ratzefummel</td>
<td>1001</td>
<td>1,50€</td>
</tr>
</table>
</section>
<section>
Kunden
<table style="font-size: .5em">
<tr>
<td>ID</td>
<td>Vor Name</td>
<td>Nach Name</td>
<td>Straße</td>
<td>Hausnr</td>
<td>PLZ</td>
<td>Ort</td>
</tr>
<tr>
<td>1234</td>
<td>Max</td>
<td>Müller</td>
<td>Trumstrasse</td>
<td> 4</td>
<td>75179</td>
<td> Pforzheim</td>
</tr>
</table>
<hr>
<div>
Rechnungen:
<table style="font-size: .5em">
<tr>
<td>Rg Nr</td>
<td>Datum</td>
<td>KundenID</td>
<td>Artikel</td>
<td>Anzahl</td>
<td>Preis</td>
</tr>
<tr>
<td>144</td>
<td>01.04.2018</td>
<td>1234</td>
<td>Bleistift</td>
<td>1001</td>
<td>1,00</td>
</tr>
<tr>
<td>145</td>
<td>01.04.2018</td>
<td>1234</td>
<td>Tüte</td>
<td>12</td>
<td>0,10</td>
</tr>
<tr>
<td>146</td>
<td>01.04.2018</td>
<td>1234</td>
<td>Ratzefummel</td>
<td>32</td>
<td>1,50</td>
</tr>
</table>
</div>
</section>
<section>
<img src="img/Wp_Normal_1_301208_165800.JPG">
</section>
<section>
Verbindung aufnehmen:
<pre><code class="bash">~$ sudo mysql
# oder:
~$ mysql -u BENUTZERNAME -p -h localhost
</code></pre>
<ul>
<li class="fragment ">-u : Username</li>
<li class="fragment ">-p : Passwort abfragen</li>
<li class="fragment ">-h : Host</li>
</ul>
</section>
<section>Datenbank erstellen
<pre style="font-size:.4em"><code class="sql">CREATE DATABASE IF NOT EXISTS test;
USE test;
CREATE TABLE IF NOT EXISTS books (
BookID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Title VARCHAR(100) NOT NULL,
SeriesID INT, AuthorID INT);
CREATE TABLE IF NOT EXISTS authors
(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT);
CREATE TABLE IF NOT EXISTS series
(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT);
INSERT INTO books (Title,SeriesID,AuthorID)
VALUES('The Fellowship of the Ring',1,1),
('The Two Towers',1,1), ('The Return of the King',1,1),
('The Sum of All Men',2,2), ('Brotherhood of the Wolf',2,2),
('Wizardborn',2,2), ('The Hobbbit',0,1);</code></pre>
</section>
<section>Tabellen anzeigen
<pre><code class="sql">
SHOW TABLES;
+----------------+
| Tables_in_test |
+----------------+
| authors |
| books |
| series |
+----------------+
3 rows in set (0.00 sec)
</code></pre>
</section>
<section>
<pre><code class="sql">DESCRIBE books;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| BookID | int(11) | NO | PRI | NULL | auto_increment |
| Title | varchar(100) | NO | | NULL | |
| SeriesID | int(11) | YES | | NULL | |
| AuthorID | int(11) | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+
</code></pre>
</section>
<section>
Daten anzeigen:
<pre><code class="sql">SELECT * FROM books;
+--------+----------------------------+----------+----------+
| BookID | Title | SeriesID | AuthorID |
+--------+----------------------------+----------+----------+
| 1 | The Fellowship of the Ring | 1 | 1 |
| 2 | The Two Towers | 1 | 1 |
| 3 | The Return of the King | 1 | 1 |
| 4 | The Sum of All Men | 2 | 2 |
| 5 | Brotherhood of the Wolf | 2 | 2 |
| 6 | Wizardborn | 2 | 2 |
| 7 | The Hobbbit | 0 | 1 |
+--------+----------------------------+----------+----------+
7 rows in set (0.00 sec)</code></pre></section>
<section>Daten einfügen:
<pre><code class="sql">INSERT INTO books (Title, SeriesID, AuthorID)
VALUES ("Lair of Bones", 2, 2);
Query OK, 1 row affected (0.00 sec)</code></pre>
<pre><code>SELECT * FROM books;</code></pre></section>
<section>
Daten modifizieren:
<pre><code class="sql">UPDATE books
SET Title = "The Hobbit"
WHERE BookID = 7;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0</code></pre>
</section>
<section>
Speicherort: <pre><code>/var/lib/mysql</code></pre>
Konfiguration <pre><code>/etc/mysql/my.cnf</code></pre>
</section>
<section>
Andere Datenbanken:
<p><ul>
<li class="fragment ">PostgreSql</li>
<li class="fragment ">SQLite</li>
<li class="fragment ">Redis</li>
<li class="fragment ">MongoDB</li>
</ul>
</section>
<section data-transition="slide" data-background="#b5533c" data-background-transition="convex"> <h3>Apache Webserver</h3></section>
<section>
<ul>
<li>Apache ist der meistgenutzte (?) Webserver</li>
<li class="fragment ">Apache beantwortet http Requests. </li>
<li class="fragment ">Punkt.</li>
<li class="fragment ">kennt Module -> Funtionserweiterung</li>
<li class="fragment ">interpretiert versch. Script-Sprachen über Module</li>
<li class="fragment "><a href="https://de.wikipedia.org/wiki/Apache_HTTP_Server#Module">Liste der Module</a></li>
<li class="fragment ">php, ruby, perl, lua, JavaScript, .net .....</li>
</ul>
</section>
<section>
<ul>
<li>aktuelle Version 2.3 ( deswegen apache2 )</li>
<li class="fragment ">Standard Speicherort f. Webseiten: /var/www/html</li>
<li class="fragment ">Aufruf per Browser : <br>http://localhost/ <br>http://SERVER-IP_ODER_NAME/</li>
<li class="fragment ">Standardmässig wird <code>index.html</code> ausgeliefert</li>
<li class="fragment ">wenn nicht vorhanden Liste des Verz. Inhalt</li>
<li class="fragment ">Steuerung über <br><code>systemctl start | stop | restart | reload | force-reload apache2</code> </li>
</ul>
</section>
<section>
<h4>Konfiguration</h4>
<ul>
<li class="fragment "><code>/etc/apache2/apache2.conf</code></li>
<li class="fragment ">Zusätzliche conf Files: <br><code>/etc/apache2/conf-available/</code></li>
<li class="fragment ">Einzelne Webseiten ( vhosts ) <br><code>/etc/apache2/sites-available/</code></li>
<li class="fragment ">per Verzeichnis: <code>.htaccess</code></li>
</ul>
</section>
<section>
De-/ Aktivieren einer Zusätzlichen Konfigurationsdatei <pre><code class="bash">~$ sudo a2enconf NAME_DER_DATEI.conf
~$ sudo a2disconf NAME_DER_DATEI.conf </code></pre>
De-/ Aktivieren einer Zusätzlichen Webseite <pre><code class="bash">~$ sudo a2ensite MEINE_WEBSEITE.conf
~$ sudo a2dissite MEINE_WEBSEITE.conf </code></pre>
<small>Diese beiden Befehle machen Symlinks in die Ordner <br><code>/etc/apache/[ conf | site ]-enabled</code></small>
<hr>
<p>Nach Änderungen in diesen Dateien: <pre><code class="bash">~$ sudo systemctl reload apache2</code></pre>
</section>
<section>
<h4>Virtual Hosts</h4>
<div>Es ist möglich, von einem Server verschiedene Domains auszuliefern mit sog. Virtual Hosts.</div>
<p>Beispiel:: <a href="beispiele/15/schubertdaniel.conf">beispiele/15/schubertdaniel.conf</a>
</section>
<section>
<span style="color: orange">Aufgabe:</span> <p>Erstellt eine Webseite namens omikron, die per <p><code>http://localhost/omikron</code> <br>aus dem Ordner <p><code>/var/www/html/omikron</code> <br>ausgeliefert wird.
</section>
<section><span style="color: orange">Aufgabe:</span> <p>Verlegt die Wordpress Installation nach <code>/home/NUTZERNAME/www/wordpress</code></section>
<!--
<section>
Übungen
C 11.11 [3] Besorgen Sie sich eine geeignete Datei (etwa ein größeres tar -Ar-
chiv mit Quellcode, vielleicht für den Linux-Kernel) und komprimieren Sie
sie jeweils mit gzip , bzip2 und xz . Messen Sie dabei die Ausführungszeit
durch ein vorgesetztes time . Wie verhalten die Laufzeiten und die Kompri-
mierungsraten sich zueinander?
C 11.12 [2] Experimentieren Sie mit der Datei aus der vorigen Aufgabe und
vergleichen Sie die Laufzeit und die Größe des Resultats für xz mit verschie-
denen Effizienz-Optionen. Was ist der Unterschied zwischen -1 und -6 und
zwischen -6 und -9 ?
</section>
-->
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/search/search.js', async: true },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>