Arborescence des pages

Vous regardez une version antérieure (v. /wiki/display/ES/Installation+de+la+plateforme+Pod+V3) de cette page.

afficher les différences afficher l'historique de la page

« Afficher la version précédente Vous regardez la version actuelle de cette page. (v. 29) afficher la version suivante »

Les commandes suivantes ont été lancées sur une distribution Debian 11.4

Environnement

Création de l'utilisateur Pod

user@pod:~$  sudo adduser pod
user@pod:~$  adduser pod sudo
user@pod:~$  su pod
user@pod:~$  cd /home/pod

Installation de paquets

pod@pod:~$ sudo apt-get install git curl vim

Création de l'environnement virtuel

pod@pod:~$ sudo python3 -V
pod@pod:~$ sudo python -V
pod@pod:~$ sudo apt-get install -y python3-pip
pod@pod:~$ sudo pip3 install virtualenvwrapper


À la fin du .bashrc, il faut ajouter ces lignes :

pod@pod:~$ vim .bashrc
      [..]
      export WORKON_HOME=$HOME/.virtualenvs
      export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
      source /usr/local/bin/virtualenvwrapper.sh
      [..]


Puis prendre en charge ces modifications :

pod@pod:$ source .bashrc

Et enfin créez l‘environnement virtuel :

pod@pod:~$ mkvirtualenv --system-site-packages --python=/usr/bin/python3 django_pod3

Récupération des sources

Concernant l’emplacement du projet, je conseille de le mettre dans /usr/local/django_projects

(django_pod3)pod@pod:~$ sudo mkdir /usr/local/django_projects

Vous pouvez faire un lien symbolique dans votre home pour arriver plus vite dans le répertoire django_projects :

(django_pod3)pod@pod:~$ ln -s /usr/local/django_projects django_projects

Placez-vous dans le répertoire django_projects

(django_pod3)pod@pod:~$ cd django_projects

Donnez les droits à l'utilisateur pod de lire et d‘écrire dans le répertoire :

(django_pod3) pod@pod:~/django_projects$ sudo chown pod:pod /usr/local/django_projects

Vous pouvez enfin récupérer les sources :

Remarque

Si vous devez utiliser un proxy, vous pouvez le spécifier avec cette commande :

(django_pod3) pod@pod:~/django_projects$ git config --global http.proxy http://PROXY:PORT

La récupération des sources de la V3 se fait via cette commande : git clone https://github.com/EsupPortail/Esup-Pod.git podv3

(django_pod3) pod@pod:~/django_projects$ git clone https://github.com/EsupPortail/Esup-Pod.git podv3
Clonage dans 'podv3'...
remote: Counting objects: 4578, done.
remote: Compressing objects: 100% (378/378), done.
remote: Total 4578 (delta 460), reused 564 (delta 348), pack-reused 3847
Réception d'objets: 100% (4578/4578), 4.40 MiB | 3.88 MiB/s, fait.
Résolution des deltas: 100% (3076/3076), fait.

(django_pod3) pod@pod:~/django_projects$ cd podv3/

Applications tierces

Installation de toutes les librairies python

Il faut vérifier que l’on se trouve bien dans l’environnement virtuel (présence de "(django_pod3)" au début l'invite de commande. Sinon, il faut lancer la commande $> workon django_pod3

(django_pod3) pod@pod:~/django_projects/podv3$ pip3 install -r requirements.txt 

De même, si vous devez utiliser un proxy :

(django_pod3) pod@pod:~/django_projects/podv3$ pip3 install --proxy="PROXY:PORT" -r requirements.txt


FFMPEG

Pour l'encodage des vidéos et la creation des vignettes, il faut installer ffmpeg, ffmpegthumbnailer et imagemagick (ne pas installer sur le serveur frontal si vous déportez l'encodage)

(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get install ffmpeg
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get install ffmpegthumbnailer
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get install imagemagick


Redis

Voir la doc officielle https://redis.io/docs/getting-started/

Pour installer le cache Redis

(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get install redis-server

En théorie le service démarre automatiquement. Si vous avez installé Redis sur la même machine que Pod, rien à faire de plus. Pour vérifier si le service est bien démarré :

(django_pod3) pod@pod:~/django_projects/podv3$ sudo service redis-server status

Si vous utilisez Redis sur une autre machine, n'oubliez pas de modifier le bind dans le fichier de configuration /etc/redis/redis.conf

Elasticsearch

Installation de Java

Pour utiliser Elasticsearch, il faut avoir java 11 sur sa machine.

(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get install openjdk-11-jre

Puis pour installer Elasticsearch sur Debian en utilisant les paquets, il faut suivre les instructions situées à cette adresse : https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html.

Vous pouvez installer Elasticsearch en version 6 ou en version 7.

Voici :

(django_pod3) pod@pod:~/django_projects/podv3$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
OK
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get install apt-transport-https

Pour Elasticsearch 6 :

(django_pod3) pod@pod:~/django_projects/podv3$ echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list deb https://artifacts.elastic.co/packages/6.x/apt stable main
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get update && sudo apt-get install elasticsearch

Pour Elasticsearch 7 :

(django_pod3) pod@pod:~/django_projects/podv3$ echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get update && sudo apt-get install elasticsearch

Ensuite il faut paramétrer l’instance :

(django_pod3) pod@pod:~/django_projects/podv3$ sudo vim /etc/elasticsearch/elasticsearch.yml

Pour préciser ces valeurs :
Pour Elasticsearch 6 :

cluster.name: pod-application
node.name: pod-1
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]

Pour Elasticsearch 7 :

cluster.name: pod-application
node.name: pod-1
discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["pod-1"]

Il faut enfin le lancer et vérifier son bon fonctionnement :

(django_pod3) pod@pod:~/django_projects/podv3$ sudo /etc/init.d/elasticsearch start

(django_pod3) pod@pod:~/django_projects/podv3$ curl -XGET "127.0.0.1:9200"

{
 "name" : "pod-1",
"cluster_name" : "pod-application",
  "cluster_uuid" : "5yhs9zc4SRyjaKYyW7uabQ",
  "version" : {
    "number" : "8.4.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "f56126089ca4db89b631901ad7cce0a8e10e2fe5",
    "build_date" : "2022-08-19T19:23:42.954591481Z",
    "build_snapshot" : false,
    "lucene_version" : "9.3.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

Pour utiliser la recherche dans Pod, nous allons avoir besoin également du plugin ICU :

(django_pod3) pod@pod:~/django_projects/podv3$ cd /usr/share/elasticsearch/
(django_pod3) pod@pod:/usr/share/elasticsearch$ sudo bin/elasticsearch-plugin install analysis-icu
-> Downloading analysis-icu from elastic
[=================================================] 100%   
-> Installed analysis-icu
(django_pod3) pod@pod:/usr/share/elasticsearch$ sudo /etc/init.d/elasticsearch restart
[ ok ] Restarting elasticsearch (via systemctl): elasticsearch.service.


Création de l'index Pod

Pour une utilisation d'elasticsearch 7.X, il faut absolument :

Ajouter ES_VERSION = 7 dans votre fichier de settings et mettre à jour le client elasticsearch

(django_pod3) pod@podv3:~/django_projects/podv3$ pip3 install elasticsearch==7.10.1

Nous pouvons enfin vérifier le bon fonctionnement de l'ensemble (l’erreur affichée lors de la deletion est normale puisque l'indice n'existe pas, mais nous devons supprimer avant de créer un index dans ES) :

(django_pod3) pod@pod:/usr/share/elasticsearch$ cd ~/django_projects/podv3
(django_pod3) pod@pod:~/django_projects/podv3$ python manage.py create_pod_index
DELETE http://127.0.0.1:9200/pod [status:404 request:0.140s]
An error occured during index video deletion: 404-index_not_found_exception : no such index
Successfully create index Video
(django_pod3) pod@pod:~/django_projects/podv3$ curl -XGET "127.0.0.1:9200/pod/_search"
{"took":35,"timed_out":false,"_shards":{"total":2,"successful":2,"skipped":0,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}


Si vous déportez l'elastic search sur une autre machine, rajoutez dans le fichier settings_local.py son URL d'accès :

(django_pod3) pod@pod:~/django_projects/podv3$ vim pod/custom/settings_local.py

Copiez la ligne suivante :

ES_URL = ['http://elastic.domaine.fr:9200/']

Installation des dépendances

Pour installer les dépendances, il faut en premier installer nodejs, npm et yarm. L'installation ne fonctionne pas avec nodejs 12.x 

(django_pod3) pod@pod:~/django_projects/podv3$ curl -sL https://deb.nodesource.com/setup_18.x | sudo bash -
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt install nodejs
(django_pod3) pod@pod:~/django_projects/podv3$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
(django_pod3) pod@pod:~/django_projects/podv3$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt update
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt install yarn

CentOS

Alternativement, si vous êtes sur CentOS 8, installez les dépendances nodejs+npm et yarn ainsi :

root@pod:~/$ dnf module reset nodejs
root@pod:~/$ dnf module enable nodejs:14
root@pod:~/$ dnf module -y update nodejs
root@pod:~/$ yum install nodejs
root@pod:~/$ npm install yarn -g


Se placer dans le répertoire où est installé le package.json

(django_pod3) pod@pod:~/django_projects/podv3$ cd pod

Installez les dépendances.

(django_pod3) pod@pod:~/django_projects/podv3/pod$ yarn

Enfin, déployez les fichiers statiques.

(django_pod3) pod@pod:~/django_projects/podv3$ python manage.py collectstatic --no-input --clear

Mise en route

Base de données SQLite intégrée

Lancez le script présent à la racine afin de créer les fichiers de migration, puis de les lancer pour créer la base de données SQLite intégrée.

(django_pod3) pod@Pod:~/django_projects/podv3$ make createDB

Fichier de configuration settings_local.py

Vous devez créer un fichier de configuration local dans le dossier pod/custom.

Vous mettez dans ce fichier uniquement les variables dont vous voulez changer la valeur par défaut. Vous trouverez ci-dessous un exemple de fichier avec les principales variables à modifier : connexion à la base de données, un fichier CSS custom, le thème green de pod, retirer le langage nl, etc. Vous pouvez adapter ce fichier et le coller dans le vôtre.

(django_pod3) pod@Pod:~/django_projects/podv3$ vim pod/custom/settings_local.py



"""Django local settings for pod_project.Django version : 3.2"""

##
# The secret key for your particular Django installation.
#
# This is used to provide cryptographic signing,
# and should be set to a unique, unpredictable value.
#
# Django will not start if this is not set.
# https://docs.djangoproject.com/fr/3.2/ref/settings/#secret-key
#
# SECURITY WARNING: keep the secret key used in production secret!
# You can visit https://djecrety.ir/ to get it 
SECRET_KEY = 'A_CHANGER'

##
# DEBUG mode activation
#
# https://docs.djangoproject.com/fr/3.2/ref/settings/#debug
#
# SECURITY WARNING: MUST be set to False when deploying into production.
DEBUG = True

##
# A list of strings representing the host/domain names
# that this Django site is allowed to serve.
#
# https://docs.djangoproject.com/fr/3.2/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['localhost']

##
# A tuple that lists people who get code error notifications
#   when DEBUG=False and a view raises an exception.
#
# https://docs.djangoproject.com/fr/3.2/ref/settings/#std:setting-ADMINS
#
ADMINS = (
    ('Name', 'adminmail@univ.fr'),
)


##
# Internationalization and localization.
#
# https://docs.djangoproject.com/fr/3.2/topics/i18n/
# https://github.com/django/django/blob/master/django/conf/global_settings.py
LANGUAGES = (
    ('fr', 'Français'),
    ('en', 'English')
)

#Hide Users in navbar
HIDE_USER_TAB = True
# Hide Types tab in navbar
HIDE_TYPES_TAB = True
# Hide Tags
HIDE_TAGS = True
# Hide disciplines in navbar
HIDE_DISCIPLINES = True

##
# eMail settings
#
# https://docs.djangoproject.com/fr/3.2/ref/settings/#email-host
# https://docs.djangoproject.com/fr/3.2/ref/settings/#email-port
# https://docs.djangoproject.com/fr/3.2/ref/settings/#default-from-email
#
#   username: EMAIL_HOST_USER
#   password: EMAIL_HOST_PASSWORD
#
EMAIL_HOST = 'smtp.univ.fr'
EMAIL_PORT = 25
DEFAULT_FROM_EMAIL = 'noreply@univ.fr'

# https://docs.djangoproject.com/fr/3.2/ref/settings/#std:setting-SERVER_EMAIL
SERVER_EMAIL = 'noreply@univ.fr'

##
# THIRD PARTY APPS OPTIONNAL
#
USE_PODFILE = True

##
# TEMPLATE Settings
#
TEMPLATE_VISIBLE_SETTINGS = {

    'TITLE_SITE': 'Lille.Pod',
    'TITLE_ETB': 'Université de Lille',
    'LOGO_SITE': 'img/logoPod.svg',
    'LOGO_COMPACT_SITE': 'img/logoPod.svg',
    'LOGO_ETB': 'img/logo_etb.svg',
    'LOGO_PLAYER': 'img/logoPod.svg',
    'FOOTER_TEXT': (
        '42, rue Paul Duez',
        '59000 Lille - France',
        ('<a href="https://goo.gl/maps/AZnyBK4hHaM2"'
            ' target="_blank">Google maps</a>')
    ),
    'LINK_PLAYER': 'http://www.univ-lille.fr',
    'CSS_OVERRIDE': 'custom/mycss.css',
    'PRE_HEADER_TEMPLATE': ''
}


Vous trouverez l'ensemble des variables disponibles sur cette page :

Configuration de la plateforme

SuperUtilisateur

Il faut créer un premier utilisateur qui aura tous les pouvoirs sur votre instance.

(django_pod3) pod@Pod:~/django_projects/podv3$ python manage.py createsuperuser


Lancement des tests unitaires

Afin de vérifier que votre instance est opérationnelle, vous pouvez lancer les tests unitaires :

(django_pod3) pod@Pod:~/django_projects/podv3$ python3 -m pip install -r requirements-dev.txt 
(django_pod3) pod@Pod:~/django_projects/podv3$ python manage.py test --settings=pod.main.test_settings


Serveur de développement

Le serveur de développement permet de tester vos futures modifications facilement.

N'hésitez pas à lancer le serveur de développement pour vérifier vos modifications au fur et à mesure.

À ce niveau, vous devriez avoir le site en français et en anglais et voir l'ensemble de la page d'accueil.

(django_pod3) pod@Pod:~/django_projects/podv3$ python3 manage.py runserver @IP/DNS:8080 --insecur
--> exemple : (django_pod3) pod@pod:~/django_projects/podv3$ python manage.py runserver pod.univ.fr:8080 --insecure

- Attention -


Quand le site est lancé, il faut se rendre dans la partie administration puis dans site pour renseigner le nom de domaine de votre instance de Pod (par défaut 'example.com').

Avant la mise en production, il faut vérifier le fonctionnement de la plateforme dont l'ajout d'une vidéo, son encodage et sa suppression.

Attention, pour ajouter une vidéo, il doit y avoir au moins un type de vidéo disponible. Si vous avez correctement peuplé votre base de données avec le fichier initial_data.json vous devez au moins avoir other/autres.

il faut vérifier l'authentification CAS, le moteur de recherche etc.


  • Aucune étiquette