Outils pour utilisateurs

Outils du site


linux:apache_php_mariadb_ssl_letsencrypt

Différences

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

Lien vers cette vue comparative

linux:apache_php_mariadb_ssl_letsencrypt [2017/10/17 20:14] – [Configuration apache2] gdureuillinux:apache_php_mariadb_ssl_letsencrypt [2020/07/24 22:03] (Version actuelle) – modification externe 127.0.0.1
Ligne 4: Ligne 4:
  
 <WRAP center info 100%> <WRAP center info 100%>
-Au 09/07/2017 : Debian 9, Apache 2.4.25, PHP-FPM 7.0.19, MariaDB 10.1.23, OpenSSL 1.1.0f.+Au 17/10/2017 : Debian 9, Apache 2.4.25, PHP-FPM 7.0.19, MariaDB 10.1.23, OpenSSL 1.1.0f.
 </WRAP> </WRAP>
  
Ligne 36: Ligne 36:
 ===== Configuration de MariaDB ===== ===== Configuration de MariaDB =====
  
-La commande suivante est recommandée en environnement de production. Elle permet de sécuriser l'installation de MariaDB.+La commande suivante est recommandée en environnement de production. Elle permet de sécuriser un minimum l'installation de MariaDB.
  
 <sxh bash;> <sxh bash;>
Ligne 123: Ligne 123:
 </sxh> </sxh>
  
 +Attention, cette configuration sera globale à tout vos vhosts !
 +
 +<WRAP center info 100%>
 Alternativement, on peux ajouter php7.0-fpm directement au fichier vhost avec le code suivant : Alternativement, on peux ajouter php7.0-fpm directement au fichier vhost avec le code suivant :
  
Ligne 151: Ligne 154:
 </IfModule> </IfModule>
 </sxh> </sxh>
 +
 +On peut alors le mettre dans la section <VirtualHost>, s'appliquant ainsi seulement au domaine désiré. On peut donc faire cohabiter plusieurs versions de php en mode fpm, en fonction des besoins pour chaque domaine.
 +</WRAP>
 +
  
  
Ligne 173: Ligne 180:
  
 <WRAP center important 100%> <WRAP center important 100%>
-Cet exemple de vhost est pour apache 2.4 ! Il contiens une partie HTTP et une partie HTTPS (facultative). N'ajoutez que le nécessaire.+Cet exemple de vhost est pour apache 2.4 en HTTP ! Voir La section sur Let's Encrypt pour HTTPS.
 </WRAP> </WRAP>
  
 <sxh text;> <sxh text;>
-#Autoriser CGI-BIN 
-<Directory /usr/lib/cgi-bin> 
-        Require all granted 
-</Directory> 
- 
 ############################################################ ############################################################
 #     domain.info                                          # #     domain.info                                          #
Ligne 189: Ligne 191:
  
 <VirtualHost 192.168.10.10:80> <VirtualHost 192.168.10.10:80>
-    ServerName domain.info +    ServerName www.domain.info 
-    ServerAlias domain.info www.domain.info+    ServerAlias www.domain.info domain.info
     DocumentRoot "/home/www-data/domain.info/www"     DocumentRoot "/home/www-data/domain.info/www"
   
  #Redirection automatique vers HTTPS  #Redirection automatique vers HTTPS
-    #Redirect "/" "https://domain.info/"+    #Redirect "/" "https://www.domain.info/"
          
-    CustomLog /home/www-data/logs/apache2/domain.info-access.log combined +    CustomLog /home/www-data/logs/apache2/www.domain.info-access.log combined 
-    ErrorLog /home/www-data/logs/apache2/domain.info-error.log+    ErrorLog /home/www-data/logs/apache2/www.domain.info-error.log
          
     AccessFileName .htaccess     AccessFileName .htaccess
Ligne 209: Ligne 211:
     </Directory>     </Directory>
        
-</VirtualHost> 
- 
-##### HTTPS 
- 
-<VirtualHost 192.168.10.10:443> 
-    ServerName domain.info 
-    ServerAlias domain.info www.domain.info 
-    DocumentRoot "/home/www-data/domain.info/www" 
-  
- #Rewrite pour enlever "www" 
-    <IfModule mod_rewrite.c> 
-        RewriteEngine On 
-        RewriteCond %{HTTP_HOST} !=domain.info [NC] 
-        RewriteRule ^(.*)$ https://domain.info$1 [L,R=301] 
-    </IfModule> 
-     
-    CustomLog /home/www-data/logs/apache2/domain.info-ssl-access.log combined 
-    ErrorLog /home/www-data/logs/apache2/domain.info-ssl-error.log 
-     
-    AccessFileName .htaccess 
- 
-    <Directory "/home/www-data/domain.info/www"> 
- DirectoryIndex index.php index.html 
- Options FollowSymLinks 
- AllowOverride All 
- Order Deny,Allow 
- Require all granted 
-    </Directory> 
-     
- <IfModule mod_ssl.c> 
- SSLEngine on 
- SSLCertificateFile "/etc/letsencrypt/live/domain.info/cert.pem" 
- SSLCertificateKeyFile "/etc/letsencrypt/live/domain.info/privkey.pem" 
-                SSLCertificateChainFile "/etc/letsencrypt/live/domain.info//chain.pem" 
- Header always set Strict-Transport-Security "max-age=31556926; preload" 
- </IfModule> 
 </VirtualHost> </VirtualHost>
 </sxh> </sxh>
Ligne 252: Ligne 218:
 La ligne commentée ''Redirect'' forcera l'utilisation de HTTPS. La décommenter quand HTTPS sera configuré et son fonctionnement validé. La ligne commentée ''Redirect'' forcera l'utilisation de HTTPS. La décommenter quand HTTPS sera configuré et son fonctionnement validé.
  
-Copier ou rendre le vhost disponible dans ''/etc/apache2/sites-available/domain.info.conf'' :+Copier ou rendre le vhost disponible dans ''/etc/apache2/sites-available/www.domain.info.conf''. Ici on fait un lien symbolique :
  
 <sxh bash;> <sxh bash;>
-ln -s /home/www-data/domain.info/domain.info.conf /etc/apache2/sites-available/domain.info.conf+ln -s /home/www-data/domain.info/www.domain.info.conf /etc/apache2/sites-available/www.domain.info.conf
 </sxh> </sxh>
  
-Puis :+Donnez les bons droits sur le fichier de configuration pour Apache 2 :
  
 <sxh bash;> <sxh bash;>
-a2ensite domain.info+chown www-data:www-data /home/www-data/domain.info/www.domain.info.conf 
 +</sxh> 
 + 
 +Puis activer cette configuration : 
 + 
 +<sxh bash;> 
 +a2ensite www.domain.info
 </sxh> </sxh>
  
Ligne 267: Ligne 239:
  
 ===== Let's Encrypt et CertBot ===== ===== Let's Encrypt et CertBot =====
 +
 +Cette partie concerne l'ajout d'un certificat pour SSL pour passer en HTTPS.
  
 Commencer par récupérer CertBot dans un dossier. Commencer par récupérer CertBot dans un dossier.
Ligne 312: Ligne 286:
 SSLUseStapling On SSLUseStapling On
 SSLStaplingCache "shmcb:${APACHE_RUN_DIR}/stapling_cache(128000)" SSLStaplingCache "shmcb:${APACHE_RUN_DIR}/stapling_cache(128000)"
 +</sxh>
 +
 +Ajoutez ensuite les informations au VirtualHost de votre site pour HTTPS :
 +
 +<sxh text>
 +##### HTTPS
 +
 +<VirtualHost 192.168.10.10:443>
 +    ServerName www.domain.info
 +    ServerAlias www.domain.info domain.info
 +    DocumentRoot "/home/www-data/domain.info/www"
 +
 + #Rewrite pour forcer "www"
 +    <IfModule mod_rewrite.c>
 +        RewriteEngine On
 +        RewriteCond %{HTTP_HOST} !^www.domain.info [NC]
 +        RewriteRule ^(.*)$ https://www.domain.info$1 [L,R=301]
 +    </IfModule>
 +    
 +    CustomLog /home/www-data/logs/apache2/www.domain.info-ssl-access.log combined
 +    ErrorLog /home/www-data/logs/apache2/www.domain.info-ssl-error.log
 +    
 +    AccessFileName .htaccess
 +
 +    <Directory "/home/www-data/domain.info/www">
 + DirectoryIndex index.php index.html
 + Options FollowSymLinks
 + AllowOverride All
 + Order Deny,Allow
 + Require all granted
 +    </Directory>
 +    
 + <IfModule mod_ssl.c>
 + SSLEngine on
 + SSLCertificateFile "/etc/letsencrypt/live/domain.info/cert.pem"
 + SSLCertificateKeyFile "/etc/letsencrypt/live/domain.info/privkey.pem"
 + SSLCertificateChainFile "/etc/letsencrypt/live/domain.info//chain.pem"
 + Header always set Strict-Transport-Security "max-age=31556926; preload"
 + </IfModule>
 +</VirtualHost>
 </sxh> </sxh>
  
Ligne 351: Ligne 365:
 ===== Sources ===== ===== Sources =====
  
-[[https://certbot.eff.org/#debianwheezy-apache|Source 1]] - [[https://gist.github.com/hroling/85f36e86d48285f08161|Source 2]] - [[http://morknet.de/smork/entry/wie-man-ein-a-rating-bei-ssllabs-erhaelt/|Source 3]] - [[https://www.ssllabs.com|Source 4]] - [[https://www.howtoforge.com/using-php5-fpm-with-apache2-on-ubuntu-12.04-lts|Source 5]] - [[https://www.digitalocean.com/community/questions/apache-2-4-with-php5-fpm|Source 6]] - [[https://www.digitalocean.com/community/tutorials/how-to-optimize-apache-web-server-performance|Source 7]] - [[https://wiki.apache.org/httpd/PHP-FPM|Source 8]] - [[http://askubuntu.com/questions/524770/apache-enable-worker-mpm/525035|Source 9]] - [[https://ma.ttias.be/apache-2-4-proxypass-for-php-taking-precedence-over-filesfilesmatch-in-htaccess/|Source 10]] - [[http://serverfault.com/questions/439692/apache-and-multiple-php-fpm-pools|Source 11]] - [[https://www.guillaume-leduc.fr/une-autre-facon-dutiliser-php-fpm.html|Source 12]] - [[https://www.croc-informatique.fr/2009/06/rotation-des-logs-avec-logrotate/|Source 13]] - [[https://www.croc-informatique.fr/2009/06/rotation-des-logs-avec-logrotate/|Source 14]] - [[https://www.abyssproject.net/2017/06/monter-serveur-web-debian-9/|Source 15]]+[[https://certbot.eff.org/#debianwheezy-apache|certbot.eff.org]] - [[https://gist.github.com/hroling/85f36e86d48285f08161|github.com/hroling]] - [[http://morknet.de/smork/entry/wie-man-ein-a-rating-bei-ssllabs-erhaelt/|morknet.de]] - [[https://www.ssllabs.com|ssllabs.com]] - [[https://www.howtoforge.com/using-php5-fpm-with-apache2-on-ubuntu-12.04-lts|howtoforge.com]] - [[https://www.digitalocean.com/community/questions/apache-2-4-with-php5-fpm|digitalocean.com]] - [[https://www.digitalocean.com/community/tutorials/how-to-optimize-apache-web-server-performance|digitalocean.com]] - [[https://wiki.apache.org/httpd/PHP-FPM|wiki.apache.org]] - [[http://askubuntu.com/questions/524770/apache-enable-worker-mpm/525035|askubuntu.com]] - [[https://ma.ttias.be/apache-2-4-proxypass-for-php-taking-precedence-over-filesfilesmatch-in-htaccess/|ma.ttias.be]] - [[http://serverfault.com/questions/439692/apache-and-multiple-php-fpm-pools|serverfault.com]] - [[https://www.guillaume-leduc.fr/une-autre-facon-dutiliser-php-fpm.html|guillaume-leduc.fr]] - [[https://www.croc-informatique.fr/2009/06/rotation-des-logs-avec-logrotate/|croc-informatique.fr]] - [[https://www.abyssproject.net/2017/06/monter-serveur-web-debian-9/|abyssproject.net]]
linux/apache_php_mariadb_ssl_letsencrypt.1508271293.txt.gz · Dernière modification : 2020/07/24 22:03 (modification externe)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki