index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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. <title>Installation d'un serveur web - The Yojik Server Installation Guide</title>
  9. <link rel="shortcut icon" href="../img/favicon.ico">
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
  11. <link rel="stylesheet" href="../css/theme.css" type="text/css" />
  12. <link rel="stylesheet" href="../css/theme_extra.css" type="text/css" />
  13. <link rel="stylesheet" href="../css/highlight.css">
  14. <script>
  15. // Current page data
  16. var mkdocs_page_name = "Installation d'un serveur web";
  17. var mkdocs_page_input_path = "9-neuf.md";
  18. var mkdocs_page_url = "/9-neuf/";
  19. </script>
  20. <script src="../js/jquery-2.1.1.min.js"></script>
  21. <script src="../js/modernizr-2.8.3.min.js"></script>
  22. <script type="text/javascript" src="../js/highlight.pack.js"></script>
  23. <script src="../js/theme.js"></script>
  24. </head>
  25. <body class="wy-body-for-nav" role="document">
  26. <div class="wy-grid-for-nav">
  27. <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
  28. <div class="wy-side-nav-search">
  29. <a href=".." class="icon icon-home"> The Yojik Server Installation Guide</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" />
  33. </form>
  34. </div>
  35. </div>
  36. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  37. <ul class="current">
  38. <li>
  39. <li class="toctree-l1 ">
  40. <a class="" href="..">Home</a>
  41. </li>
  42. <li>
  43. <li>
  44. <li class="toctree-l1 ">
  45. <a class="" href="../1-un/">Installation d'un serveur Debian/Stretch sécurisé</a>
  46. </li>
  47. <li>
  48. <li>
  49. <li class="toctree-l1 ">
  50. <a class="" href="../2-deux/">Premières étapes de sécurisation du serveur</a>
  51. </li>
  52. <li>
  53. <li>
  54. <li class="toctree-l1 ">
  55. <a class="" href="../3-trois/">Configuration du réseau</a>
  56. </li>
  57. <li>
  58. <li>
  59. <li class="toctree-l1 ">
  60. <a class="" href="../4-quatre/">Installation d'un serveur de temps</a>
  61. </li>
  62. <li>
  63. <li>
  64. <li class="toctree-l1 ">
  65. <a class="" href="../5-cinq/">Installation d'un pare-feu</a>
  66. </li>
  67. <li>
  68. <li>
  69. <li class="toctree-l1 ">
  70. <a class="" href="../6-six/">Contrer les attaques de brute-force avec fail2ban</a>
  71. </li>
  72. <li>
  73. <li>
  74. <li class="toctree-l1 ">
  75. <a class="" href="../7-sept/">Installation d'un serveur de courrier basique</a>
  76. </li>
  77. <li>
  78. <li>
  79. <li class="toctree-l1 ">
  80. <a class="" href="../8-huit/">Installation du serveur DNS</a>
  81. </li>
  82. <li>
  83. <li>
  84. <li class="toctree-l1 current">
  85. <a class="current" href="./">Installation d'un serveur web</a>
  86. <ul>
  87. <li class="toctree-l3"><a href="#installation-dun-serveur-web">Installation d'un serveur web</a></li>
  88. <li><a class="toctree-l4" href="#sauvegarde-de-notre-nouvelle-configuration">Sauvegarde de notre nouvelle configuration</a></li>
  89. <li><a class="toctree-l4" href="#creation-des-hotes-virtuels-virtual-hosts">Création des hôtes virtuels (virtual hosts)</a></li>
  90. <li><a class="toctree-l4" href="#creation-des-fichiers-html">Création des fichiers html</a></li>
  91. </ul>
  92. </li>
  93. <li>
  94. <li>
  95. <li class="toctree-l1 ">
  96. <a class="" href="../10-dix/">Installation de dovecot et de l'authentification</a>
  97. </li>
  98. <li>
  99. <li>
  100. <li class="toctree-l1 ">
  101. <a class="" href="../11-onze/">Installation des certificats letsencrypt</a>
  102. </li>
  103. <li>
  104. <li>
  105. <li class="toctree-l1 ">
  106. <a class="" href="../12-douze/">Ajout des enregistrements SPF et DKIM au fichier de zone DNS</a>
  107. </li>
  108. <li>
  109. <li>
  110. <li class="toctree-l1 ">
  111. <a class="" href="../17-dixsept/">Installation de programmes de surveillance du serveur</a>
  112. </li>
  113. <li>
  114. <li>
  115. <li class="toctree-l1 ">
  116. <a class="" href="../18-dixhuit/">Installation d'un webmail</a>
  117. </li>
  118. <li>
  119. <li>
  120. <li class="toctree-l1 ">
  121. <a class="" href="../19-dixneuf/">Installation de git et de gogs</a>
  122. </li>
  123. <li>
  124. </ul>
  125. </div>
  126. &nbsp;
  127. </nav>
  128. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  129. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  130. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  131. <a href="..">The Yojik Server Installation Guide</a>
  132. </nav>
  133. <div class="wy-nav-content">
  134. <div class="rst-content">
  135. <div role="navigation" aria-label="breadcrumbs navigation">
  136. <ul class="wy-breadcrumbs">
  137. <li><a href="..">Docs</a> &raquo;</li>
  138. <li>Installation d'un serveur web</li>
  139. <li class="wy-breadcrumbs-aside">
  140. </li>
  141. </ul>
  142. <hr/>
  143. </div>
  144. <div role="main">
  145. <div class="section">
  146. <h2 id="installation-dun-serveur-web">Installation d'un serveur web</h2>
  147. <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>
  148. <pre><code class="shell">root@aijan:/etc/bind# apt install apache2
  149. Lecture des listes de paquets... Fait
  150. Construction de l'arbre des dépendances
  151. Lecture des informations d'état... Fait
  152. The following additional packages will be installed:
  153. apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
  154. etc ...
  155. </code></pre>
  156. <p>Test de notre serveur:</p>
  157. <p>C'est bon, voilà une image de la page d'acceuil :</p>
  158. <p><img alt="Le serveur apache" src="../Images/apache.png" /></p>
  159. <p>Ne pas oublier d'ouvrir les ports du firewall: port 80 et 443 en TCP et UDP.</p>
  160. <p>Lignes à rajouter à firewall.sh:</p>
  161. <pre><code class="shell"> # HTTP + HTTPS Out
  162. $IPT -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
  163. $IPT -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
  164. $IP6T -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
  165. $IP6T -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
  166. # HTTP + HTTPS In
  167. $IPT -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
  168. $IPT -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
  169. $IP6T -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
  170. $IP6T -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
  171. </code></pre>
  172. <h3 id="sauvegarde-de-notre-nouvelle-configuration">Sauvegarde de notre nouvelle configuration</h3>
  173. <pre><code class="shell">root@aijan:#cd /home/ericadmin/bin/
  174. root@aijan:/home/ericadmin/bin#./firewall.sh restart
  175. root@aijan:/home/ericadmin/bin#service netfilter-persistent save
  176. </code></pre>
  177. <h3 id="creation-des-hotes-virtuels-virtual-hosts">Création des hôtes virtuels (virtual hosts)</h3>
  178. <p>3 hôtes virtuels à créer:</p>
  179. <ul>
  180. <li>yojik.net</li>
  181. <li>www.yojik.net</li>
  182. <li>yazik.yojik.net</li>
  183. </ul>
  184. <p>Créez 2 fichiers d'hôtes virtuels. Exemple de fichier:</p>
  185. <p><strong>Virtualhost: www.yojik.net</strong></p>
  186. <pre><code class="shell">&lt;VirtualHost *:80&gt;
  187. ServerAdmin webmaster@yojik.net
  188. ServerName www.yojik.net
  189. DocumentRoot /var/www/html/yojiknet/
  190. &lt;Directory &quot;/var/www/html/yojiknet/index.html&quot;&gt;
  191. Options Indexes MultiViews
  192. AllowOverride FileInfo AuthConfig Indexes
  193. Order allow,deny
  194. allow from all
  195. Require all granted
  196. &lt;/Directory&gt;
  197. ErrorLog ${APACHE_LOG_DIR}/error.log
  198. CustomLog ${APACHE_LOG_DIR}/access.log combined
  199. LogLevel warn
  200. &lt;/VirtualHost&gt;
  201. </code></pre>
  202. <p><strong>Virtualhost: yazik.yojik.net</strong></p>
  203. <pre><code class="shell">&lt;VirtualHost *:80&gt;
  204. ServerAdmin webmaster@yojik.net
  205. ServerName yazik.yojik.net
  206. DocumentRoot /var/www/html/yaziknet/
  207. &lt;Directory &quot;/var/www/html/yaziknet/index.html&quot;&gt;
  208. Options Indexes MultiViews
  209. AllowOverride FileInfo AuthConfig Indexes
  210. Order allow,deny
  211. allow from all
  212. Require all granted
  213. &lt;/Directory&gt;
  214. ErrorLog ${APACHE_LOG_DIR}/error.log
  215. CustomLog ${APACHE_LOG_DIR}/access.log combined
  216. LogLevel warn
  217. &lt;/VirtualHost&gt;
  218. </code></pre>
  219. <p>Validez-les avec:</p>
  220. <blockquote>
  221. <p>a2ensite le_nom_du_fichier (a2ensite site1 site2 (pour moi))</p>
  222. </blockquote>
  223. <p>On recharge apache2 pour la prise en compte de nos 2 sites.</p>
  224. <blockquote>
  225. <p>service apache2 reload</p>
  226. </blockquote>
  227. <h3 id="creation-des-fichiers-html">Création des fichiers html</h3>
  228. <p>Créez 2 répertoires sous /var/www/html:</p>
  229. <ul>
  230. <li>
  231. <p>mkdir /var/www/html/yojiknet /var/www/html/yaziknet</p>
  232. </li>
  233. <li>
  234. <p>cd /var/www/html</p>
  235. </li>
  236. </ul>
  237. <p>On crée un fichier <strong>index.html</strong> sous chaque répertoire créé:</p>
  238. <p>Exemple de fichier de base:</p>
  239. <p><strong>/var/www/html/yojiknet/index.html</strong></p>
  240. <pre><code class="shell">&lt;!DOCTYPE html&gt;
  241. &lt;html&gt;
  242. &lt;head&gt;
  243. &lt;title&gt;The Yojik.net home page&lt;/title&gt;
  244. &lt;meta charset=&quot;UTF-8&quot;&gt;
  245. &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
  246. &lt;/head&gt;
  247. &lt;body&gt;
  248. &lt;h1&gt;The Yojik Net home page&lt;/h1&gt;
  249. &lt;p&gt;Nothing interesting at the moment .. comming soon!&lt;/p&gt;
  250. &lt;/body&gt;
  251. &lt;/html&gt;
  252. </code></pre>
  253. <p><strong>/var/www/html/yaziknet/index.html</strong></p>
  254. <pre><code class="shell">&lt;!DOCTYPE html&gt;
  255. &lt;html&gt;
  256. &lt;head&gt;
  257. &lt;title&gt;The Yazik.net home page&lt;/title&gt;
  258. &lt;meta charset=&quot;UTF-8&quot;&gt;
  259. &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
  260. &lt;/head&gt;
  261. &lt;body&gt;
  262. &lt;h1&gt;The Yazik Net home page&lt;/h1&gt;
  263. &lt;p&gt;Nothing interesting at the moment .. comming soon!&lt;/p&gt;
  264. &lt;/body&gt;
  265. &lt;/html&gt;
  266. </code></pre>
  267. <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>
  268. <blockquote>
  269. <p>chown -Rv www-data.www-data *</p>
  270. </blockquote>
  271. <p>On relance apache</p>
  272. <blockquote>
  273. <p>service apache2 restart</p>
  274. </blockquote>
  275. <p>On teste avec un navigateur.</p>
  276. <ul>
  277. <li>
  278. <p>adresse 1: www.yojik.net</p>
  279. </li>
  280. <li>
  281. <p>adresse 2: yazik.yojik.net</p>
  282. </li>
  283. </ul>
  284. <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>
  285. <blockquote>
  286. <p>yazik IN CNAME atom.yojik.net.</p>
  287. </blockquote>
  288. <p>Re-testez: tout marche :)</p>
  289. </div>
  290. </div>
  291. <footer>
  292. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  293. <a href="../10-dix/" class="btn btn-neutral float-right" title="Installation de dovecot et de l'authentification">Next <span class="icon icon-circle-arrow-right"></span></a>
  294. <a href="../8-huit/" class="btn btn-neutral" title="Installation du serveur DNS"><span class="icon icon-circle-arrow-left"></span> Previous</a>
  295. </div>
  296. <hr/>
  297. <div role="contentinfo">
  298. <!-- Copyright etc -->
  299. </div>
  300. Built with <a href="http://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>.
  301. </footer>
  302. </div>
  303. </div>
  304. </section>
  305. </div>
  306. <div class="rst-versions" role="note" style="cursor: pointer">
  307. <span class="rst-current-version" data-toggle="rst-current-version">
  308. <span><a href="../8-huit/" style="color: #fcfcfc;">&laquo; Previous</a></span>
  309. <span style="margin-left: 15px"><a href="../10-dix/" style="color: #fcfcfc">Next &raquo;</a></span>
  310. </span>
  311. </div>
  312. </body>
  313. </html>