index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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="#sauvegarde-de-notre-nouvelle-configuration">Sauvegarde de notre nouvelle configuration</a></li>
  88. <li class="toctree-l3"><a href="#creation-des-hotes-virtuels-virtual-hosts">Création des hôtes virtuels (virtual hosts)</a></li>
  89. <li class="toctree-l3"><a href="#creation-des-fichiers-html">Création des fichiers html</a></li>
  90. </ul>
  91. </li>
  92. <li>
  93. <li>
  94. <li class="toctree-l1 ">
  95. <a class="" href="../10-dix/">Installation de dovecot et de l'authentification</a>
  96. </li>
  97. <li>
  98. <li>
  99. <li class="toctree-l1 ">
  100. <a class="" href="../11-onze/">Installation des certificats letsencrypt</a>
  101. </li>
  102. <li>
  103. <li>
  104. <li class="toctree-l1 ">
  105. <a class="" href="../12-douze/">Ajout des enregistrements SPF et DKIM au fichier de zone DNS</a>
  106. </li>
  107. <li>
  108. <li>
  109. <li class="toctree-l1 ">
  110. <a class="" href="../17-dixsept/">Installation de programmes de surveillance du serveur</a>
  111. </li>
  112. <li>
  113. <li>
  114. <li class="toctree-l1 ">
  115. <a class="" href="../18-dixhuit/">Installation d'un webmail</a>
  116. </li>
  117. <li>
  118. <li>
  119. <li class="toctree-l1 ">
  120. <a class="" href="../19-dixneuf/">Installation de git et de gogs</a>
  121. </li>
  122. <li>
  123. </ul>
  124. </div>
  125. &nbsp;
  126. </nav>
  127. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  128. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  129. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  130. <a href="..">The Yojik Server Installation Guide</a>
  131. </nav>
  132. <div class="wy-nav-content">
  133. <div class="rst-content">
  134. <div role="navigation" aria-label="breadcrumbs navigation">
  135. <ul class="wy-breadcrumbs">
  136. <li><a href="..">Docs</a> &raquo;</li>
  137. <li>Installation d'un serveur web</li>
  138. <li class="wy-breadcrumbs-aside">
  139. </li>
  140. </ul>
  141. <hr/>
  142. </div>
  143. <div role="main">
  144. <div class="section">
  145. <p>## Installation d'un serveur web</p>
  146. <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>
  147. <pre><code>root@aijan:/etc/bind# apt install apache2
  148. Lecture des listes de paquets... Fait
  149. Construction de l'arbre des dépendances
  150. Lecture des informations d'état... Fait
  151. The following additional packages will be installed:
  152. apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
  153. ...
  154. </code></pre>
  155. <p>Test de notre serveur:</p>
  156. <p>C'est bon, voilà une image de la page d'acceuil :</p>
  157. <p><img alt="Le serveur apache" src="../Images/apache.png" /></p>
  158. <p>Ne pas oublier d'ouvrir les ports du firewall: port 80 et 443 en TCP et UDP.</p>
  159. <p>Lignes à rajouter à firewall.sh:</p>
  160. <pre><code> # HTTP + HTTPS Out
  161. $IPT -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
  162. $IPT -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
  163. $IP6T -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
  164. $IP6T -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
  165. # HTTP + HTTPS In
  166. $IPT -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
  167. $IPT -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
  168. $IP6T -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
  169. $IP6T -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
  170. </code></pre>
  171. <h3 id="sauvegarde-de-notre-nouvelle-configuration">Sauvegarde de notre nouvelle configuration</h3>
  172. <pre><code>root@aijan:#cd /home/ericadmin/bin/
  173. root@aijan:/home/ericadmin/bin#./firewall.sh restart
  174. root@aijan:/home/ericadmin/bin#service netfilter-persistent save
  175. </code></pre>
  176. <h3 id="creation-des-hotes-virtuels-virtual-hosts">Création des hôtes virtuels (virtual hosts)</h3>
  177. <p>3 hôtes virtuels à créer:</p>
  178. <blockquote>
  179. <p>yojik.net
  180. www.yojik.net
  181. yazik.yojik.net</p>
  182. </blockquote>
  183. <p>Créez 2 fichiers d'hôtes virtuels. Exemple de fichier:</p>
  184. <p><strong>Virtualhost: www.yojik.net</strong></p>
  185. <pre><code>&lt;VirtualHost *:80&gt;
  186. ServerAdmin webmaster@yojik.net
  187. ServerName www.yojik.net
  188. DocumentRoot /var/www/html/yojiknet/
  189. &lt;Directory &quot;/var/www/html/yojiknet/index.html&quot;&gt;
  190. Options Indexes MultiViews
  191. AllowOverride FileInfo AuthConfig Indexes
  192. Order allow,deny
  193. allow from all
  194. Require all granted
  195. &lt;/Directory&gt;
  196. ErrorLog ${APACHE_LOG_DIR}/error.log
  197. CustomLog ${APACHE_LOG_DIR}/access.log combined
  198. LogLevel warn
  199. &lt;/VirtualHost&gt;
  200. </code></pre>
  201. <p><strong>Virtualhost: yazik.yojik.net</strong></p>
  202. <pre><code>&lt;VirtualHost *:80&gt;
  203. ServerAdmin webmaster@yojik.net
  204. ServerName yazik.yojik.net
  205. DocumentRoot /var/www/html/yaziknet/
  206. &lt;Directory &quot;/var/www/html/yaziknet/index.html&quot;&gt;
  207. Options Indexes MultiViews
  208. AllowOverride FileInfo AuthConfig Indexes
  209. Order allow,deny
  210. allow from all
  211. Require all granted
  212. &lt;/Directory&gt;
  213. ErrorLog ${APACHE_LOG_DIR}/error.log
  214. CustomLog ${APACHE_LOG_DIR}/access.log combined
  215. LogLevel warn
  216. &lt;/VirtualHost&gt;
  217. </code></pre>
  218. <p>Validez-les avec:</p>
  219. <blockquote>
  220. <p>a2ensite le_nom_du_fichier (a2ensite site1 site2 (pour moi))</p>
  221. </blockquote>
  222. <p>On recharge apache2 pour la prise en compte de nos 2 sites.</p>
  223. <blockquote>
  224. <p>service apache2 reload</p>
  225. </blockquote>
  226. <h3 id="creation-des-fichiers-html">Création des fichiers html</h3>
  227. <p>Créez 2 répertoires sous /var/www/html:</p>
  228. <blockquote>
  229. <p>mkdir /var/www/html/yojiknet /var/www/html/yaziknet</p>
  230. <p>cd /var/www/html</p>
  231. </blockquote>
  232. <p>On crée 2 fichiers <strong>index.html</strong> sous chaque répertoire créé:</p>
  233. <p>Exemple de fichier de base:</p>
  234. <p><strong>/var/www/html/yojiknet/index.html</strong></p>
  235. <pre><code>&lt;!DOCTYPE html&gt;
  236. &lt;html&gt;
  237. &lt;head&gt;
  238. &lt;title&gt;The Yojik.net home page&lt;/title&gt;
  239. &lt;meta charset=&quot;UTF-8&quot;&gt;
  240. &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
  241. &lt;/head&gt;
  242. &lt;body&gt;
  243. &lt;h1&gt;The Yojik Net home page&lt;/h1&gt;
  244. &lt;p&gt;Nothing interesting at the moment .. comming soon!&lt;/p&gt;
  245. &lt;/body&gt;
  246. &lt;/html&gt;
  247. </code></pre>
  248. <p><strong>/var/www/html/yaziknet/index.html</strong></p>
  249. <pre><code>&lt;!DOCTYPE html&gt;
  250. &lt;html&gt;
  251. &lt;head&gt;
  252. &lt;title&gt;The Yazik.net home page&lt;/title&gt;
  253. &lt;meta charset=&quot;UTF-8&quot;&gt;
  254. &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
  255. &lt;/head&gt;
  256. &lt;body&gt;
  257. &lt;h1&gt;The Yazik Net home page&lt;/h1&gt;
  258. &lt;p&gt;Nothing interesting at the moment .. comming soon!&lt;/p&gt;
  259. &lt;/body&gt;
  260. &lt;/html&gt;
  261. </code></pre>
  262. <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>
  263. <blockquote>
  264. <p>chown -Rv www-data.www-data *</p>
  265. </blockquote>
  266. <p>On relance apache</p>
  267. <blockquote>
  268. <p>service apache2 restart</p>
  269. </blockquote>
  270. <p>On crée un </p>
  271. <p>On teste avec un navigateur.</p>
  272. <p>adresse 1: www.yojik.net</p>
  273. <p>adresse 2: yazik.yojik.net</p>
  274. <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>
  275. <blockquote>
  276. <p>yazik IN CNAME atom.yojik.net.</p>
  277. </blockquote>
  278. <p>Re-testez: tout marche :)</p>
  279. </div>
  280. </div>
  281. <footer>
  282. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  283. <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>
  284. <a href="../8-huit/" class="btn btn-neutral" title="Installation du serveur DNS"><span class="icon icon-circle-arrow-left"></span> Previous</a>
  285. </div>
  286. <hr/>
  287. <div role="contentinfo">
  288. <!-- Copyright etc -->
  289. </div>
  290. 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>.
  291. </footer>
  292. </div>
  293. </div>
  294. </section>
  295. </div>
  296. <div class="rst-versions" role="note" style="cursor: pointer">
  297. <span class="rst-current-version" data-toggle="rst-current-version">
  298. <span><a href="../8-huit/" style="color: #fcfcfc;">&laquo; Previous</a></span>
  299. <span style="margin-left: 15px"><a href="../10-dix/" style="color: #fcfcfc">Next &raquo;</a></span>
  300. </span>
  301. </div>
  302. </body>
  303. </html>