Arborescence des pages

Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

Avertissement

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

Sommaire

Environnement

...

Création de l'utilisateur Pod

Bloc de code
user@pod:~$  sudo adduser pod
user@pod:~$  adduser pod sudo
user@pod:~$  su pod

...

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


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

...

Bloc de code
pod@pod:$ source .bashrc

Et enfin créer créez l‘environnement virtuel :

...

Bloc de code
(django_pod) pod@pod:~/django_projects/podv3$ sudo apt-get installservice 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.

Bloc de code
(django_pod) pod@pod:~/django_projects/podv2$ sudo apt-get install openjdk-11-jre

Puis pour installer Elasticsearch sur Debian en utilsant 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 :

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

...

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

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

...

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

...


Création de l'index Pod

Avertissement

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_pod) 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 normal normale puisque l'indice n'existe pas, mais nous devons supprimer avant de créer un index dans ES) :

...

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

Bloc de code
(django_pod) pod@pod:~/django_projects/podv3$ vim pod/custom/settings_local.py

copier Copiez la ligne suivante :

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

...

Bloc de code
(django_pod) pod@pod:~/django_projects/podv3$ cd pod

Installer Installez les dépendances.

Bloc de code
(django_pod) pod@pod:~/django_projects/podv3/pod$ yarn

Enfin, déployer déployez les fichiers statiques.

Bloc de code
(django_pod) pod@pod:~/django_projects/podv3$ python manage.py collectstatic --no-input --clear

...

Base de données SQLite intégrée

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

Bloc de code
languagebash
(django_pod) pod@Pod:~/django_projects/podv3$ make createDB

...

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édonnées, un fichier css CSS custom, le thème green de pod, retirer le langage nl, etc .. . Vous pouvez adapter ce fichier et le coller dans le votrevôtre.


Bloc de code
languagepy
"""Django local settings for pod_project.Django version : 1.11.10."""

##
# 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/en/1.11/ref/settings/#secret-key
#
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'A_CHANGER'

##
# DEBUG mode activation
#
# https://docs.djangoproject.com/en/1.11/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/en/1.11/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['localhost', '192.168.1.8']

##
# A tuple that lists people who get code error notifications
#   when DEBUG=False and a view raises an exception.
#
# https://docs.djangoproject.com/fr/1.11/ref/settings/#std:setting-ADMINS
#
ADMINS = (
    ('Name', 'adminmail@univ.fr'),
)
# configuration exemple pour utiliser une base de données MySql, 
# voir ci-apprès l'installation de lib tierce nécessaire
# il est possible d'utiliser d'autres moteur de bases de données (PostGreSql...)
# https://docs.djangoproject.com/fr/1.11/ref/databases/
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mydatabase',
        'USER': 'mydatabaseuser',
        'PASSWORD': 'mypassword',
        'HOST': '127.0.0.1',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET storage_engine=INNODB, sql_mode='STRICT_TRANS_TABLES', innodb_strict_mode=1",
         },
    }
}

##
# Internationalization and localization.
#
# https://docs.djangoproject.com/en/1.11/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/en/1.11/ref/settings/#email-host
# https://docs.djangoproject.com/en/1.11/ref/settings/#email-port
# https://docs.djangoproject.com/en/1.11/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/1.11/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': ''
}
# Choose a theme for your pod website
# 'default' is the simpliest, bootstrap $enable_rounded is true
# 'green' is with a dark green for primary color, $enable_rounded is false
# 'dark' is black and red, without grey background, $enable_rounded is false
USE_THEME = 'green'


# Custom Bootstrap CSS file. Example : custom/bootstrap-default.min.css
BOOTSTRAP_CUSTOM = ''

...

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

...