linux:apache_php_mariadb_ssl_letsencrypt
Différences
Ci-dessous, les différences entre deux révisions de la page.
linux:apache_php_mariadb_ssl_letsencrypt [2017/10/17 16:58] – [Exemple de fichier vhost] gdureuil | linux: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. |
</ | </ | ||
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' | + | La commande suivante est recommandée en environnement de production. Elle permet de sécuriser |
<sxh bash;> | <sxh bash;> | ||
Ligne 110: | Ligne 110: | ||
===== Configuration apache2 ===== | ===== Configuration apache2 ===== | ||
- | Passage en mpm_worker | + | Désactiver php7.0 |
<sxh bash;> | <sxh bash;> | ||
- | apachectl -V | grep -i mpm | + | a2dismod |
- | a2dismod | + | |
- | a2enmod mpm_worker | + | |
- | service apache2 restart | + | |
- | apachectl -V | grep -i mpm | + | |
</ | </ | ||
- | Désactiver le fichier de configuration par défaut d' | + | Activer php7.0-fpm |
<sxh bash;> | <sxh bash;> | ||
- | a2dissite 000-default | + | a2enconf php7.0-fpm |
- | service apache2 reload | + | |
</ | </ | ||
- | ===== Exemple de fichier vhost ===== | + | Attention, cette configuration sera globale à tout vos vhosts ! |
- | <WRAP center | + | <WRAP center |
- | Cet exemple de vhost est pour apache 2.4 ! Il contiens une partie HTTP et une partie HTTPS (facultative). N' | + | Alternativement, |
- | </ | + | |
<sxh text;> | <sxh text;> | ||
- | #Autoriser CGI-BIN | + | ##### PHP7.0-FPM ##### |
- | < | + | |
- | Require all granted | + | |
- | </ | + | |
- | + | ||
- | ############################################################ | + | |
- | # | + | |
- | ############################################################ | + | |
- | + | ||
- | ##### PHP7.0-FPM | + | |
< | < | ||
Ligne 167: | Ligne 153: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
+ | |||
+ | On peut alors le mettre dans la section < | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | Passage en mpm_worker pour apache2 : | ||
+ | |||
+ | <sxh bash;> | ||
+ | apachectl -V | grep -i mpm | ||
+ | a2dismod mpm_prefork | ||
+ | a2enmod mpm_worker | ||
+ | service apache2 restart | ||
+ | apachectl -V | grep -i mpm | ||
+ | </ | ||
+ | |||
+ | Désactiver le fichier de configuration par défaut d' | ||
+ | |||
+ | <sxh bash;> | ||
+ | a2dissite 000-default | ||
+ | service apache2 reload | ||
+ | </ | ||
+ | |||
+ | ===== Exemple de fichier vhost ===== | ||
+ | |||
+ | <WRAP center important 100%> | ||
+ | Cet exemple de vhost est pour apache 2.4 en HTTP ! Voir La section sur Let's Encrypt pour HTTPS. | ||
+ | </ | ||
+ | |||
+ | <sxh text;> | ||
+ | ############################################################ | ||
+ | # | ||
+ | ############################################################ | ||
##### HTTP | ##### HTTP | ||
< | < | ||
- | ServerName domain.info | + | ServerName |
- | ServerAlias domain.info | + | ServerAlias |
DocumentRoot "/ | DocumentRoot "/ | ||
# | # | ||
- | #Redirect "/" | + | #Redirect "/" |
| | ||
- | CustomLog / | + | CustomLog / |
- | ErrorLog / | + | ErrorLog / |
| | ||
AccessFileName .htaccess | AccessFileName .htaccess | ||
Ligne 191: | Ligne 211: | ||
</ | </ | ||
- | </ | ||
- | |||
- | ##### HTTPS | ||
- | |||
- | < | ||
- | ServerName domain.info | ||
- | ServerAlias domain.info www.domain.info | ||
- | DocumentRoot "/ | ||
- | |||
- | #Rewrite pour enlever " | ||
- | < | ||
- | RewriteEngine On | ||
- | RewriteCond %{HTTP_HOST} !=domain.info [NC] | ||
- | RewriteRule ^(.*)$ https:// | ||
- | </ | ||
- | | ||
- | CustomLog / | ||
- | ErrorLog / | ||
- | | ||
- | AccessFileName .htaccess | ||
- | |||
- | < | ||
- | DirectoryIndex index.php index.html | ||
- | Options FollowSymLinks | ||
- | AllowOverride All | ||
- | Order Deny,Allow | ||
- | Require all granted | ||
- | </ | ||
- | | ||
- | < | ||
- | SSLEngine on | ||
- | SSLCertificateFile "/ | ||
- | SSLCertificateKeyFile "/ | ||
- | SSLCertificateChainFile "/ | ||
- | Header always set Strict-Transport-Security " | ||
- | </ | ||
</ | </ | ||
</ | </ | ||
Ligne 234: | Ligne 218: | ||
La ligne commentée '' | La ligne commentée '' | ||
- | Copier ou rendre le vhost disponible dans ''/ | + | Copier ou rendre le vhost disponible dans ''/ |
<sxh bash;> | <sxh bash;> | ||
- | ln -s / | + | ln -s / |
</ | </ | ||
- | Puis : | + | Donnez les bons droits sur le fichier de configuration pour Apache 2 : |
<sxh bash;> | <sxh bash;> | ||
- | a2ensite domain.info | + | chown www-data: |
+ | </ | ||
+ | |||
+ | Puis activer cette configuration : | ||
+ | |||
+ | <sxh bash;> | ||
+ | a2ensite | ||
</ | </ | ||
Ligne 249: | Ligne 239: | ||
===== Let's Encrypt et CertBot ===== | ===== Let's Encrypt et CertBot ===== | ||
+ | |||
+ | Cette partie concerne l' | ||
Commencer par récupérer CertBot dans un dossier. | Commencer par récupérer CertBot dans un dossier. | ||
Ligne 294: | Ligne 286: | ||
SSLUseStapling On | SSLUseStapling On | ||
SSLStaplingCache " | SSLStaplingCache " | ||
+ | </ | ||
+ | |||
+ | Ajoutez ensuite les informations au VirtualHost de votre site pour HTTPS : | ||
+ | |||
+ | <sxh text> | ||
+ | ##### HTTPS | ||
+ | |||
+ | < | ||
+ | ServerName www.domain.info | ||
+ | ServerAlias www.domain.info domain.info | ||
+ | DocumentRoot "/ | ||
+ | |||
+ | #Rewrite pour forcer " | ||
+ | < | ||
+ | RewriteEngine On | ||
+ | RewriteCond %{HTTP_HOST} !^www.domain.info [NC] | ||
+ | RewriteRule ^(.*)$ https:// | ||
+ | </ | ||
+ | | ||
+ | CustomLog / | ||
+ | ErrorLog / | ||
+ | | ||
+ | AccessFileName .htaccess | ||
+ | |||
+ | < | ||
+ | DirectoryIndex index.php index.html | ||
+ | Options FollowSymLinks | ||
+ | AllowOverride All | ||
+ | Order Deny,Allow | ||
+ | Require all granted | ||
+ | </ | ||
+ | | ||
+ | < | ||
+ | SSLEngine on | ||
+ | SSLCertificateFile "/ | ||
+ | SSLCertificateKeyFile "/ | ||
+ | SSLCertificateChainFile "/ | ||
+ | Header always set Strict-Transport-Security " | ||
+ | </ | ||
+ | </ | ||
</ | </ | ||
Ligne 333: | Ligne 365: | ||
===== Sources ===== | ===== Sources ===== | ||
- | [[https:// | + | [[https:// |
linux/apache_php_mariadb_ssl_letsencrypt.1508259524.txt.gz · Dernière modification : 2020/07/24 22:03 (modification externe)