Outils pour utilisateurs

Outils du site


server:installation

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
server:installation [2019/05/06 13:06]
kevin [Configurer SSH]
server:installation [2019/05/12 18:21] (Version actuelle)
kevin [HTTPS]
Ligne 1: Ligne 1:
 ====== Installation et configuration d'un serveur Debian ====== ====== Installation et configuration d'un serveur Debian ======
- 
-===== À faire ===== 
-  * Installer Apache 
-  * Installer MySQL 
-  * Installer PHP 
-  * Installer pare-feu (iptable ? fail2ban ?) 
-  * Installer serveur NTP ? 
  
 ===== Préparation du disque d'installation ===== ===== Préparation du disque d'installation =====
Ligne 25: Ligne 18:
  
 Personnalisations : Personnalisations :
- +  * Ne pas forcer l'installation UEFI. 
-Ne pas forcer l'installation UEFI. +  Schéma de partitionnement du disque : ''separate /home, /var, and /tmp partitions'' et garder les valeurs proposées.
- +
-Schéma de partitionnement du disque : separate /home, /var, and /tmp partitions et garder les valeurs proposées.+
  
 ===== Installer sudo ===== ===== Installer sudo =====
Ligne 88: Ligne 79:
 <file bash> <file bash>
 PermitRootLogin no PermitRootLogin no
-AllowUsers administrator+AllowUsers toto
 </file> </file>
  
Ligne 153: Ligne 144:
 :INPUT DROP [0:0] :INPUT DROP [0:0]
 :FORWARD DROP [0:0] :FORWARD DROP [0:0]
-:OUTPUT ACCEPT [687:218631]+:OUTPUT ACCEPT [0:0]
  
 # Allow internal traffic on the loopback device # Allow internal traffic on the loopback device
Ligne 281: Ligne 272:
   * https://sebsauvage.net/wiki/doku.php?id=mint_customization_17_3#autres   * https://sebsauvage.net/wiki/doku.php?id=mint_customization_17_3#autres
   * https://doc.ubuntu-fr.org/fail2ban   * https://doc.ubuntu-fr.org/fail2ban
 +
 +===== Installer et configurer ddclient =====
 +''ddclient'' est un client dynamic DNS.
 +
 +Installer ''ddclient'' :
 +<code bash>
 +sudo apt install ddclient
 +</code>
 +
 +Éditer le fichier de configuration :
 +<code bash>
 +sudo nano /etc/ddclient.conf
 +</code>
 +
 +<file bash>
 +# Configuration file for ddclient generated by debconf
 +#
 +# /etc/ddclient.conf
 +
 +syslog=yes
 +#verbose=yes
 +daemon=21600
 +ssl=yes
 +protocol=dyndns2
 +use=web
 +server=www.ovh.com
 +login=mondomaine.net-login
 +password='password'
 +dyn.mondomaine.net
 +</file>
 +
 +<WRAP center round important 60%>
 +Le paquet ''libio-socket-ssl-perl'' doit être installé pour que la connexion SSL puisse s'établir !
 +</WRAP>
 +
 +Redémarrer le service :
 +<code bash>
 +sudo service ddclient restart
 +</code>
 +
 +Vérifier que le service soit démarré :
 +<code bash>
 +sudo /etc/init.d/ddclient status
 +</code>
 +
 +Vérifier que le processus est en cours :
 +<code bash>
 +sudo ps aux | grep ddclient
 +</code>
 +
 +Vérifier les logs :
 +<code bash>
 +sudo cat /var/log/daemon.log | grep ddclient
 +</code>
 +
 +==== Sources ====
 +  * https://www.lacaveatonton.ovh/ddclient-le-client-dynhost-sous-linux/
 +  * https://help.ubuntu.com/community/DynamicDNS
 +  * https://doc.ubuntu-fr.org/ddclient
 +  * https://perhonen.fr/blog/2016/03/dynhost-dyndns-de-chez-ovh-2446
 +  * https://www.monlinux.net/2014/08/dns-dynamique-client-no-ip-dyndns-debian/
 +
 +===== Services web (Apache, MariaDB, PHP) =====
 +==== MariaDB ====
 +Installer MariaDB :
 +<code bash>
 +sudo apt install mariadb-server mariadb-client
 +</code>
 +
 +Lancer l'assistant de sécurisation :
 +<code bash>
 +sudo mysql_secure_installation
 +</code>
 +
 +<code [enable_line_numbers="true",highlight_lines_extra="9,15,16,17,28,34,41,50"]>
 +NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
 +      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
 +
 +In order to log into MariaDB to secure it, we'll need the current
 +password for the root user.  If you've just installed MariaDB, and
 +you haven't set the root password yet, the password will be blank,
 +so you should just press enter here.
 +
 +Enter current password for root (enter for none):
 +OK, successfully used password, moving on...
 +
 +Setting the root password ensures that nobody can log into the MariaDB
 +root user without the proper authorisation.
 +
 +Set root password? [Y/n] y
 +New password: <mot de passe>
 +Re-enter new password: <mot de passe>
 +Password updated successfully!
 +Reloading privilege tables..
 + ... Success!
 +
 +
 +By default, a MariaDB installation has an anonymous user, allowing anyone
 +to log into MariaDB without having to have a user account created for
 +them.  This is intended only for testing, and to make the installation
 +go a bit smoother.  You should remove them before moving into a
 +production environment.
 +
 +Remove anonymous users? [Y/n] y
 + ... Success!
 +
 +Normally, root should only be allowed to connect from 'localhost' This
 +ensures that someone cannot guess at the root password from the network.
 +
 +Disallow root login remotely? [Y/n] y
 + ... Success!
 +
 +By default, MariaDB comes with a database named 'test' that anyone can
 +access.  This is also intended only for testing, and should be removed
 +before moving into a production environment.
 +
 +Remove test database and access to it? [Y/n] y
 + - Dropping test database...
 + ... Success!
 + - Removing privileges on test database...
 + ... Success!
 +
 +Reloading the privilege tables will ensure that all changes made so far
 +will take effect immediately.
 +
 +Reload privilege tables now? [Y/n] y
 + ... Success!
 +
 +Cleaning up...
 +
 +All done!  If you've completed all of the above steps, your MariaDB
 +installation should now be secure.
 +
 +Thanks for using MariaDB!
 +</code>
 +
 +MariaDB est dès à présent sécurisé.
 +
 +=== Créer un utilisateur avec tous les privilèges ===
 +<code bash>
 +sudo mysql
 +</code>
 +
 +<code sql>
 +GRANT ALL ON *.* TO 'nom_utilisateur'@'localhost' IDENTIFIED BY 'mot_de_passe' WITH GRANT OPTION;
 +</code>
 +<code sql>
 +FLUSH PRIVILEGES;
 +</code>
 +<code sql>
 +QUIT;
 +</code>
 +
 +==== Apache ====
 +Installer Apache :
 +<code bash>
 +sudo apt install apache2
 +</code>
 +
 +Ajouter une règle dans le pare-feu (voir [[installation#configurer_le_pare-feu|cette section]]) :
 +<file bash>
 +# Accept HTTP
 +-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
 +</file>
 +
 +Chemins à connaître :
 +  * Racine des documents : ''/var/www''
 +  * Fichier de configuration : ''/etc/apache2/apache2.conf''
 +  * Modules : ''/etc/apache2/mods-enabled''
 +  * Virtual hosts : ''/etc/apache2/sites-enabled''
 +  * Global configuration fragments : ''/etc/apache2/conf-enabled''
 +
 +=== Déplacer le répertoire www ===
 +Copier le répertoire ''/var/www/'' et son contenu dans le nouvel emplacement (ici, ''/home/www/'') :
 +<code bash>
 +sudo cp -r /var/www/ /home/www/
 +</code>
 +
 +Il est également possible de copier le répertoire (et les droits associés) avec [[https://www.digitalocean.com/community/tutorials/how-to-move-an-apache-web-root-to-a-new-location-on-debian-8|rsync]].
 +
 +Remplacer toutes les occurrences de ''/var/www/'' par le nouveau chemin dans les fichiers suivants :
 +  * ''/etc/apache2/apache2.conf''
 +  * ''/etc/apache2/sites-enabled/000-default.conf''
 +  * ''/etc/apache2/sites-available/default-ssl.conf''
 +
 +Redémarrer Apache :
 +<code bash>
 +sudo systemctl restart apache2
 +</code>
 +
 +==== PHP ====
 +Installer PHP et plusieurs modules courants :
 +<code bash>
 +sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-intl php-json php-mbstring php-xml php-zip php-sqlite3 php-imagick php-mcrypt php-memcache
 +</code>
 +
 +Redémarrer Apache :
 +<code bash>
 +sudo systemctl restart apache2
 +</code>
 +
 +Tester :
 +<code bash>
 +sudo nano /home/www/html/info.php
 +</code>
 +
 +<file php info.php>
 +<?php
 +phpinfo();
 +</file>
 +
 +==== phpMyAdmin ====
 +Installer phpMyAdmin :
 +<code bash>
 +sudo apt install phpmyadmin
 +</code>
 +
 +FIXME Configurer
 +
 +Tester le fonctionnement de phpMyAdmin en se rendant sur http://192.168.1.10/phpmyadmin
 +
 +S'il n'est pas accessible, il faut modifier la configuration du serveur Apache.
 +
 +Éditer ''/etc/apache2/apache2.conf'' :
 +<code bash>
 +sudo nano /etc/apache2/apache2.conf
 +</code>
 +
 +Ajouter la ligne suivante à la fin du fichier :
 +<file bash>
 +Include /etc/phpmyadmin/apache.conf
 +</file>
 +
 +Redémarrer le serveur Apache :
 +<code bash>
 +sudo systemctl restart apache2
 +</code>
 +
 +==== HTTPS ====
 +Activer le module SSL :
 +<code bash>
 +sudo a2enmod ssl
 +</code>
 +
 +Recharger la configuration d'Apache :
 +<code bash>
 +sudo systemctl reload apache2
 +</code>
 +
 +Finalement, suivre les instructions données [[https://doc.ubuntu-fr.org/apache2#mise_en_place_de_https_avec_certbot|ici]].
 +
 +<WRAP center round important 60%>
 +Ne pas oublier d'ouvrir le port 443 dans le pare-feu !
 +</WRAP>
 +
 +
 +==== Sources ====
 +  * https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-lamp-on-debian-stretch/
 +  * https://doc.ubuntu-fr.org/lamp
 +  * https://doc.ubuntu-fr.org/tutoriel/lamp_repertoires_de_travail
 +  * https://doc.ubuntu-fr.org/apache2
 +  * https://doc.ubuntu-fr.org/php
 +  * https://doc.ubuntu-fr.org/mariadb
 +  * https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-debian
 +  * https://www.linode.com/docs/web-servers/lamp/lamp-on-debian-8-jessie/
  
 ===== Divers liens utiles ===== ===== Divers liens utiles =====
   * https://www.howtoforge.com/   * https://www.howtoforge.com/
   * https://wiki.debian.org/   * https://wiki.debian.org/
server/installation.1557140780.txt.gz · Dernière modification: 2019/05/06 13:06 de kevin