index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <link rel="shortcut icon" href="../img/favicon.ico">
  9. <title>Installation d'un serveur web - Les Tutoriels du Yojik</title>
  10. <link rel="stylesheet" href="../css/theme.css" />
  11. <link rel="stylesheet" href="../css/theme_extra.css" />
  12. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" />
  13. <script>
  14. // Current page data
  15. var mkdocs_page_name = "Installation d'un serveur web";
  16. var mkdocs_page_input_path = "Installation-Serveur-Web.md";
  17. var mkdocs_page_url = null;
  18. </script>
  19. <script src="../js/jquery-2.1.1.min.js" defer></script>
  20. <script src="../js/modernizr-2.8.3.min.js" defer></script>
  21. <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
  22. <script>hljs.initHighlightingOnLoad();</script>
  23. </head>
  24. <body class="wy-body-for-nav" role="document">
  25. <div class="wy-grid-for-nav">
  26. <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
  27. <div class="wy-side-scroll">
  28. <div class="wy-side-nav-search">
  29. <a href=".." class="icon icon-home"> Les Tutoriels du Yojik</a>
  30. <div role="search">
  31. <form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
  32. <input type="text" name="q" placeholder="Search docs" title="Type search term here" />
  33. </form>
  34. </div>
  35. </div>
  36. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  37. <p class="caption"><span class="caption-text">Installation d'un serveur sécurisé, version Debian/Stretch (obsolète)</span></p>
  38. <ul>
  39. <li class="toctree-l1"><a class="reference internal" href="..">Présentation</a>
  40. </li>
  41. </ul>
  42. <p class="caption"><span class="caption-text">Installation</span></p>
  43. <ul class="current">
  44. <li class="toctree-l1"><a class="reference internal" href="../Installation-de-base/">Installation du système de base</a>
  45. </li>
  46. <li class="toctree-l1"><a class="reference internal" href="../ovh/">Démarrage sur serveur OVH</a>
  47. </li>
  48. <li class="toctree-l1"><a class="reference internal" href="../Premi%C3%A8re-Etape-S%C3%A9curisation/">Première étapes de sécurisation du serveur</a>
  49. </li>
  50. <li class="toctree-l1"><a class="reference internal" href="../Configuration-R%C3%A9seau/">Configuration du réseau</a>
  51. </li>
  52. <li class="toctree-l1"><a class="reference internal" href="../Installation-Serveur-Temps/">Installation d'un serveur de temps</a>
  53. </li>
  54. <li class="toctree-l1"><a class="reference internal" href="../Installation-Parre-Feu/">Installation d'un pare-feu</a>
  55. </li>
  56. <li class="toctree-l1"><a class="reference internal" href="../Installation-Fail2ban/">Contrer les attaques de brute-force avec fail2ban</a>
  57. </li>
  58. <li class="toctree-l1"><a class="reference internal" href="../Installation-Serveur-Courrier-Basique/">Installation d'un serveur de courrier basique</a>
  59. </li>
  60. <li class="toctree-l1"><a class="reference internal" href="../Installation-Serveur-DNS/">Installation du serveur DNS</a>
  61. </li>
  62. <li class="toctree-l1 current"><a class="reference internal current" href="./">Installation d'un serveur web</a>
  63. <ul class="current">
  64. <li class="toctree-l2"><a class="reference internal" href="#sauvegarde-de-notre-nouvelle-configuration">Sauvegarde de notre nouvelle configuration</a>
  65. </li>
  66. <li class="toctree-l2"><a class="reference internal" href="#creation-des-hotes-virtuels-virtual-hosts">Création des hôtes virtuels (virtual hosts)</a>
  67. </li>
  68. <li class="toctree-l2"><a class="reference internal" href="#creation-des-fichiers-html">Création des fichiers html</a>
  69. </li>
  70. </ul>
  71. </li>
  72. <li class="toctree-l1"><a class="reference internal" href="../Installation-Dovecot-Authentification/">Installation de dovecot et de l'authentification</a>
  73. </li>
  74. <li class="toctree-l1"><a class="reference internal" href="../Installation-Certificats-Letsencrypt/">Installation des certificats letsencrypt</a>
  75. </li>
  76. <li class="toctree-l1"><a class="reference internal" href="../Courrier-SPF-DKIM-OPENDMARC/">Ajout des enregistrements **spf**, **DKIM**, **DMARC** au fichier de zone DNS</a>
  77. </li>
  78. <li class="toctree-l1"><a class="reference internal" href="../Courrier-Comptes-Virtuels/">Ajout des comptes émail virtuels</a>
  79. </li>
  80. <li class="toctree-l1"><a class="reference internal" href="../Surveillance-Serveur/">Installation de programmes de surveillance du serveur</a>
  81. </li>
  82. <li class="toctree-l1"><a class="reference internal" href="../Installation-Webmail/">Installation d'un webmail (rainloop)</a>
  83. </li>
  84. <li class="toctree-l1"><a class="reference internal" href="../S%C3%A9curisation-Serveur-Web/">Sécurisation d'un serveur WEB</a>
  85. </li>
  86. </ul>
  87. </div>
  88. </div>
  89. </nav>
  90. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  91. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  92. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  93. <a href="..">Les Tutoriels du Yojik</a>
  94. </nav>
  95. <div class="wy-nav-content">
  96. <div class="rst-content">
  97. <div role="navigation" aria-label="breadcrumbs navigation">
  98. <ul class="wy-breadcrumbs">
  99. <li><a href="..">Docs</a> &raquo;</li>
  100. <li>Installation &raquo;</li>
  101. <li>Installation d'un serveur web</li>
  102. <li class="wy-breadcrumbs-aside">
  103. </li>
  104. </ul>
  105. <hr/>
  106. </div>
  107. <div role="main">
  108. <div class="section">
  109. <h1 id="installation-dun-serveur-web">Installation d'un serveur web</h1>
  110. <p>Nous allons installer un serveur Web: <strong>Apache</strong>. C'est juste celui que je connais le mieux. <strong>Nginx</strong> est une possible alternative très prisée et guère plus compliquée à mettre en oeuvre.</p>
  111. <pre><code>root@aijan:/etc/bind# apt install apache2
  112. Lecture des listes de paquets... Fait
  113. Construction de l'arbre des dépendances
  114. Lecture des informations d'état... Fait
  115. The following additional packages will be installed:
  116. apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
  117. etc ...
  118. </code></pre>
  119. <p>Test de notre serveur:</p>
  120. <p>C'est bon, voilà une image de la page d'acceuil :</p>
  121. <p><img alt="Le serveur apache" src="../Images/apache.png" /></p>
  122. <p>Ne pas oublier d'ouvrir les ports du firewall: port 80 et 443 en TCP et UDP.</p>
  123. <p>Lignes à rajouter à firewall.sh:</p>
  124. <pre><code> # HTTP + HTTPS Out
  125. $IPT -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
  126. $IPT -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
  127. $IP6T -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
  128. $IP6T -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
  129. # HTTP + HTTPS In
  130. $IPT -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
  131. $IPT -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
  132. $IP6T -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
  133. $IP6T -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
  134. </code></pre>
  135. <h2 id="sauvegarde-de-notre-nouvelle-configuration">Sauvegarde de notre nouvelle configuration</h2>
  136. <pre><code>root@aijan:#cd /home/ericadmin/bin/
  137. root@aijan:/home/ericadmin/bin#./firewall.sh restart
  138. root@aijan:/home/ericadmin/bin#service netfilter-persistent save
  139. </code></pre>
  140. <h2 id="creation-des-hotes-virtuels-virtual-hosts">Création des hôtes virtuels (virtual hosts)</h2>
  141. <p>3 hôtes virtuels à créer:</p>
  142. <ul>
  143. <li>yojik.net</li>
  144. <li>www.yojik.net</li>
  145. <li>yazik.yojik.net</li>
  146. </ul>
  147. <p>Créez 2 fichiers d'hôtes virtuels. Exemple de fichier:</p>
  148. <p><strong>Virtualhost: www.yojik.net</strong></p>
  149. <pre><code>&lt;VirtualHost *:80&gt;
  150. ServerAdmin webmaster@yojik.net
  151. ServerName www.yojik.net
  152. DocumentRoot /var/www/html/yojiknet/
  153. &lt;Directory "/var/www/html/yojiknet/index.html"&gt;
  154. Options Indexes MultiViews
  155. AllowOverride FileInfo AuthConfig Indexes
  156. Order allow,deny
  157. allow from all
  158. Require all granted
  159. &lt;/Directory&gt;
  160. ErrorLog ${APACHE_LOG_DIR}/error.log
  161. CustomLog ${APACHE_LOG_DIR}/access.log combined
  162. LogLevel warn
  163. &lt;/VirtualHost&gt;
  164. </code></pre>
  165. <p><strong>Virtualhost: yazik.yojik.net</strong></p>
  166. <pre><code>&lt;VirtualHost *:80&gt;
  167. ServerAdmin webmaster@yojik.net
  168. ServerName yazik.yojik.net
  169. DocumentRoot /var/www/html/yaziknet/
  170. &lt;Directory "/var/www/html/yaziknet/index.html"&gt;
  171. Options Indexes MultiViews
  172. AllowOverride FileInfo AuthConfig Indexes
  173. Order allow,deny
  174. allow from all
  175. Require all granted
  176. &lt;/Directory&gt;
  177. ErrorLog ${APACHE_LOG_DIR}/error.log
  178. CustomLog ${APACHE_LOG_DIR}/access.log combined
  179. LogLevel warn
  180. &lt;/VirtualHost&gt;
  181. </code></pre>
  182. <p>Validez-les avec:</p>
  183. <pre><code>a2ensite le_nom_du_fichier (a2ensite site1 site2 (pour moi))
  184. </code></pre>
  185. <p>On recharge apache2 pour la prise en compte de nos 2 sites.</p>
  186. <pre><code>service apache2 reload
  187. </code></pre>
  188. <h2 id="creation-des-fichiers-html">Création des fichiers html</h2>
  189. <p>Créez 2 répertoires sous /var/www/html:</p>
  190. <pre><code>mkdir /var/www/html/yojiknet /var/www/html/yaziknet
  191. cd /var/www/html
  192. </code></pre>
  193. <p>On crée un fichier <strong>index.html</strong> sous chaque répertoire créé:</p>
  194. <p>Exemple de fichier de base:</p>
  195. <p><code>/var/www/html/yojiknet/index.html</code></p>
  196. <pre><code>&lt;!DOCTYPE html&gt;
  197. &lt;html&gt;
  198. &lt;head&gt;
  199. &lt;title&gt;The Yojik.net home page&lt;/title&gt;
  200. &lt;meta charset="UTF-8"&gt;
  201. &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
  202. &lt;/head&gt;
  203. &lt;body&gt;
  204. &lt;h1&gt;The Yojik Net home page&lt;/h1&gt;
  205. &lt;p&gt;Nothing interesting at the moment .. comming soon!&lt;/p&gt;
  206. &lt;/body&gt;
  207. </code></pre>
  208. <p></html></p>
  209. <p><code>/var/www/html/yaziknet/index.html</code></p>
  210. <pre><code>&lt;!DOCTYPE html&gt;
  211. &lt;html&gt;
  212. &lt;head&gt;
  213. &lt;title&gt;The Yazik.net home page&lt;/title&gt;
  214. &lt;meta charset="UTF-8"&gt;
  215. &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
  216. &lt;/head&gt;
  217. &lt;body&gt;
  218. &lt;h1&gt;The Yazik Net home page&lt;/h1&gt;
  219. &lt;p&gt;Nothing interesting at the moment .. comming soon!&lt;/p&gt;
  220. &lt;/body&gt;
  221. &lt;/html&gt;
  222. </code></pre>
  223. <p>Dans le répertoire <strong>/var/www/html/</strong> on lance la commande suivante pour ajuster les droits et propriétaires des fichiers (pour apache et Debian, c'est <strong>www-data</strong>.)</p>
  224. <pre><code>chown -Rv www-data.www-data *
  225. </code></pre>
  226. <p>On relance apache</p>
  227. <pre><code>service apache2 restart
  228. </code></pre>
  229. <p>On teste avec un navigateur.</p>
  230. <ul>
  231. <li>
  232. <p>adresse 1: www.yojik.net</p>
  233. </li>
  234. <li>
  235. <p>adresse 2: yazik.yojik.net</p>
  236. </li>
  237. </ul>
  238. <p>Vous vous apercevrez que la deuxième ne fonctionne pas: il vous faut ajouter le domaine yazik.yojik.net à votre fichier de zone de bind et relancer bind ensuite:</p>
  239. <pre><code>yazik IN CNAME atom.yojik.net.
  240. </code></pre>
  241. <p>Re-testez: tout marche :)</p>
  242. </div>
  243. </div>
  244. <footer>
  245. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  246. <a href="../Installation-Dovecot-Authentification/" class="btn btn-neutral float-right" title="Installation de dovecot et de l'authentification">Next <span class="icon icon-circle-arrow-right"></span></a>
  247. <a href="../Installation-Serveur-DNS/" class="btn btn-neutral" title="Installation du serveur DNS"><span class="icon icon-circle-arrow-left"></span> Previous</a>
  248. </div>
  249. <hr/>
  250. <div role="contentinfo">
  251. <!-- Copyright etc -->
  252. </div>
  253. Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  254. </footer>
  255. </div>
  256. </div>
  257. </section>
  258. </div>
  259. <div class="rst-versions" role="note" aria-label="versions">
  260. <span class="rst-current-version" data-toggle="rst-current-version">
  261. <span><a href="../Installation-Serveur-DNS/" style="color: #fcfcfc;">&laquo; Previous</a></span>
  262. <span style="margin-left: 15px"><a href="../Installation-Dovecot-Authentification/" style="color: #fcfcfc">Next &raquo;</a></span>
  263. </span>
  264. </div>
  265. <script>var base_url = '..';</script>
  266. <script src="../js/theme.js" defer></script>
  267. <script src="../search/main.js" defer></script>
  268. <script defer>
  269. window.onload = function () {
  270. SphinxRtdTheme.Navigation.enable(true);
  271. };
  272. </script>
  273. </body>
  274. </html>