Ajout d'une partie du TP4

This commit is contained in:
Tom MOGULJAK 2024-03-17 11:31:57 +01:00
commit 915052df70
9 changed files with 396 additions and 0 deletions

1
.obsidian/app.json vendored Normal file
View File

@ -0,0 +1 @@
{}

3
.obsidian/appearance.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"accentColor": ""
}

30
.obsidian/core-plugins-migration.json vendored Normal file
View File

@ -0,0 +1,30 @@
{
"file-explorer": true,
"global-search": true,
"switcher": true,
"graph": true,
"backlink": true,
"canvas": true,
"outgoing-link": true,
"tag-pane": true,
"properties": false,
"page-preview": true,
"daily-notes": true,
"templates": true,
"note-composer": true,
"command-palette": true,
"slash-command": false,
"editor-status": true,
"bookmarks": true,
"markdown-importer": false,
"zk-prefixer": false,
"random-note": false,
"outline": true,
"word-count": true,
"slides": false,
"audio-recorder": false,
"workspaces": false,
"file-recovery": true,
"publish": false,
"sync": false
}

20
.obsidian/core-plugins.json vendored Normal file
View File

@ -0,0 +1,20 @@
[
"file-explorer",
"global-search",
"switcher",
"graph",
"backlink",
"canvas",
"outgoing-link",
"tag-pane",
"page-preview",
"daily-notes",
"templates",
"note-composer",
"command-palette",
"editor-status",
"bookmarks",
"outline",
"word-count",
"file-recovery"
]

163
.obsidian/workspace.json vendored Normal file
View File

@ -0,0 +1,163 @@
{
"main": {
"id": "d01614ab684c681d",
"type": "split",
"children": [
{
"id": "005e6870b012bca6",
"type": "tabs",
"children": [
{
"id": "c0ef377f7e23ee53",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "README.md",
"mode": "source",
"source": false
}
}
}
]
}
],
"direction": "vertical"
},
"left": {
"id": "b1f2404bbafbcb32",
"type": "split",
"children": [
{
"id": "a111fbc707d995d7",
"type": "tabs",
"children": [
{
"id": "3d3befe961829175",
"type": "leaf",
"state": {
"type": "file-explorer",
"state": {
"sortOrder": "alphabetical"
}
}
},
{
"id": "301007e4e49ab711",
"type": "leaf",
"state": {
"type": "search",
"state": {
"query": "",
"matchingCase": false,
"explainSearch": false,
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical"
}
}
},
{
"id": "c9557c6aaf6ae43d",
"type": "leaf",
"state": {
"type": "bookmarks",
"state": {}
}
}
]
}
],
"direction": "horizontal",
"width": 300
},
"right": {
"id": "864f01d8447d72fc",
"type": "split",
"children": [
{
"id": "f8b6f844b06997cc",
"type": "tabs",
"children": [
{
"id": "e6fa236f32120ade",
"type": "leaf",
"state": {
"type": "backlink",
"state": {
"file": "README.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
"showSearch": false,
"searchQuery": "",
"backlinkCollapsed": false,
"unlinkedCollapsed": true
}
}
},
{
"id": "2cbcff3818eaecc2",
"type": "leaf",
"state": {
"type": "outgoing-link",
"state": {
"file": "README.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
}
},
{
"id": "d0940f5a93fc9efb",
"type": "leaf",
"state": {
"type": "tag",
"state": {
"sortOrder": "frequency",
"useHierarchy": true
}
}
},
{
"id": "e9a7a6d713930109",
"type": "leaf",
"state": {
"type": "outline",
"state": {
"file": "README.md"
}
}
}
]
}
],
"direction": "horizontal",
"width": 300,
"collapsed": true
},
"left-ribbon": {
"hiddenItems": {
"switcher:Ouvrir le sélecteur rapide": false,
"graph:Ouvrir la vue graphique": false,
"canvas:Créer une nouvelle toile": false,
"daily-notes:Ouvrir la note quotidienne": false,
"templates:Insérer le modèle": false,
"command-palette:Ouvrir la palette de commandes": false
}
},
"active": "c0ef377f7e23ee53",
"lastOpenFiles": [
"TP4/docker-compose.yml",
"TP4/nginx/default.conf",
"TP4/web/index.php",
"TP4/nginx",
"TP4/web",
"TP4",
"TP 4/nginx/default.conf",
"TP 4/nginx",
"TP 4/web/index.php",
"TP 4/web",
"TP 4"
]
}

84
README.md Normal file
View File

@ -0,0 +1,84 @@
# TP 1
# TP 2
# TP 4
**Étape 1** : Créer deux dossiers : "web" et "nginx"
**Étape 2** : Mettre le fichier ``index.php`` dans le dossier web et le fichier ``default.conf`` dans le dossier nginx
**Étape 3** : Pour déployer le server REDIS il faut ajouter ceci dans le fichier ``docker-compose.yml``
```yaml
services:
redis:
image: redis/redis-stack
ports:
- "6379:6379"
volumes:
- redis_data:/data
restart: always
```
**Étape 4** : Pour déployer le server REDISINSIGHT il faut ajouter ceci dans le fichier ``docker-compose.yml``
```yml
services:
redisinsight:
image: redis/redisinsight
ports:
- "5540:5540"
restart: always
volumes:
- redisinsight_data:/db
```
⚠️ Attention ne pas oublier de mettre à la fin du ficher un bloc volumes
```yml
volumes:
redis_data:
redisinsight_data:
```
**Étape 5** : Pour déployer le server PHP il faut ajouter ceci dans le fichier ``docker-compose.yml``
```yml
services:
php:
image: windok/php-redis
restart: always
volumes:
- ./web:/usr/share/nginx/html
environment:
NOM : "moguljak"
PRENOM : "tom"
deploy:
replicas: 2
```
**Étape 6** : Pour déployer le server NGINX il faut ajouter ceci dans le fichier ``docker-compose.yml``
```yml
services:
nginx :
image: nginx
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ./web:/usr/share/nginx/html
- ./nginx:/etc/nginx/conf.d
```
**Étape 6** : Pour initialiser la base de données deux méthodes s'offrent à nous. La première en se connectant directement au serveur REDIS et la deuxième en utilisant l'interface REDISINSIGHT.
- **Première solution**
- Démarrer docker avec la commande ``docker compose up -d``
- Effectuer la commande ``docker ps`` afin de lister tous conteneurs
- Maintenant qu'on sait sur quel docker on veut se connecter (celui de REDIS) on peut effectuer la commande suivante nous permettant d'ouvrir un Shell directement dans le docker. ``docker exec -it tp4-redis-1 /bin/bash``
- Maintenant effectuer cette commande ``redis-cli`` elle va nous permettre de définir la clef
- Et ensuite pour définir la clef on effectue ``set code 12345``
- Maintenant vous pouvez voir les changements en allant sur la page "
http://localhost/index.php"
- **Deuxième solution**
# TP 5/6

54
TP4/docker-compose.yml Normal file
View File

@ -0,0 +1,54 @@
services:
redis:
image: redis/redis-stack
ports:
- "6379:6379"
volumes:
- redis_data:/data
restart: always
networks:
- back
redisinsight:
image: redis/redisinsight
ports:
- "5540:5540"
restart: always
volumes:
- redisinsight_data:/db
networks:
- back
php:
image: windok/php-redis
restart: always
volumes:
- ./web:/usr/share/nginx/html
environment:
NOM : "moguljak"
PRENOM : "tom"
deploy:
replicas: 2
networks:
- front
- back
nginx :
image: nginx
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ./web:/usr/share/nginx/html
- ./nginx:/etc/nginx/conf.d
networks:
- front
networks:
front:
back:
volumes:
redis_data:
redisinsight_data:

14
TP4/nginx/default.conf Normal file
View File

@ -0,0 +1,14 @@
server {
server_name tp4.iut.fr;
listen 80;
root /usr/share/nginx/html;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

27
TP4/web/index.php Normal file
View File

@ -0,0 +1,27 @@
<?php
$redis = new Redis();
$redis->connect('tp4-redis-1', 6379);
$code = $redis->get('code');
echo "
<table>
<tr>
<td>SERVERNAME</td>
<td><b>".$_SERVER['SERVER_NAME']."</b></td>
</tr>
<tr>
<td>HOSTNAME</td>
<td><b>".gethostname()."</b></td>
</tr>
<tr>
<td>ETUDIANT</td>
<td><b>".$_ENV['NOM']." / ".$_ENV['PRENOM']."</b></td>
</tr>
<tr>
<td>CODE</td>
<td><b>$code</b></td>
</tr>
</table>";