Cette page vous donne les différences entre la révision choisie et la version actuelle de la page.
linux:serveur_web [2011/10/19 23:16] matthieu |
linux:serveur_web [2011/12/01 23:37] (Version actuelle) matthieu [Links] |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
{{tag>fr fr:linux fr:serveur fr:web}} | {{tag>fr fr:linux fr:serveur fr:web}} | ||
- | ====== Serveur Web ====== | + | ====== Serveur Web (Apache) ====== |
Quelle que soit le but de votre serveur, un service web est très souvent indispensable. | Quelle que soit le but de votre serveur, un service web est très souvent indispensable. | ||
Ligne 19: | Ligne 19: | ||
- | ===== Configuration ===== | + | ===== Principe de configuration ===== |
La configuration d'Apache2 est définie par le fichier ///etc/apache2/apache2.conf//. C'est un fichier à plat mais il inclue d'autres fichiers grâce à la commande Include : | La configuration d'Apache2 est définie par le fichier ///etc/apache2/apache2.conf//. C'est un fichier à plat mais il inclue d'autres fichiers grâce à la commande Include : | ||
* /etc/apache2/apache2.conf | * /etc/apache2/apache2.conf | ||
Ligne 44: | Ligne 44: | ||
</code> | </code> | ||
- | [[linux:serveur_web:config]] | + | ===== Configuration avancée ===== |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | [[linux:serveur_web:ssl]] | + | |
- | + | ||
- | + | ||
- | + | ||
- | ===== Authentification LDAP ===== | + | |
- | Ce paragraphe décrit comment configurer l'authentification LDAP dans Apache2. | + | |
- | + | ||
- | ==== Installation ==== | + | |
- | Pour l'installation d'un serveur LDAP, voir [[openldap]]. | + | |
- | + | ||
- | L'authentification LDAP d'Apache2 est réalisée par le module authnz_ldap. Son activation se fait de la façon suivante : | + | |
- | <code> | + | |
- | bender:/etc/apache2# a2enmod authnz_ldap | + | |
- | Enabling ldap as a dependency | + | |
- | Module ldap installed; run /etc/init.d/apache2 force-reload to enable. | + | |
- | Module authnz_ldap installed; run /etc/init.d/apache2 force-reload to enable. | + | |
- | bender:/etc/apache2# | + | |
- | </code> | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ==== Configuration ==== | + | |
- | + | ||
- | Voici un exemple d'authentification LDAP : | + | |
- | <file> | + | |
- | <Directory /home/ssl> | + | |
- | AuthType basic | + | |
- | AuthName "private area" | + | |
- | AuthBasicProvider ldap | + | |
- | AuthLDAPURL ldap://127.0.0.1/dc=matthieu,dc=bouthors,dc=org?cn?sub?(objectClass=*) | + | |
- | AuthLDAPBindDN cn=apache,ou=services,dc=matthieu,dc=bouthors,dc=org | + | |
- | AuthLDAPBindPassword *** | + | |
- | AuthzLDAPAuthoritative off | + | |
- | require ldap-group cn=web,ou=groups,dc=matthieu,dc=bouthors,dc=org | + | |
- | </Directory> | + | |
- | </file> | + | |
- | + | ||
- | Les principales directives à utiliser pour authentifier les utilisateurs en LDAP sont decrite ci-dessous. | + | |
- | + | ||
- | + | ||
- | + | ||
- | === AuthType === | + | |
- | ^Lien |http://httpd.apache.org/docs/2.2/mod/core.html#authtype| | + | |
- | ^Description|Définit le type d'authentification| | + | |
- | ^Syntaxe |%%AuthType Basic|Digest%%| | + | |
- | ^Contexte |directory, .htaccess| | + | |
- | + | ||
- | === AuthName === | + | |
- | ^Lien |http://httpd.apache.org/docs/2.2/mod/core.html#authname| | + | |
- | ^Description|Nom du royaume présenté à l'utilisateur| | + | |
- | ^Syntaxe |%%AuthName auth-domain%%| | + | |
- | ^Contexte |directory, .htaccess| | + | |
- | + | ||
- | === AuthBasicProvider === | + | |
- | ^Lien |http://httpd.apache.org/docs/2.2/mod/mod_auth_basic.html#authbasicprovider| | + | |
- | ^Description|Indique le moteur d'authentification pour cette URL| | + | |
- | ^Syntaxe |%%AuthBasicProvider provider-name [provider-name] ...%%| | + | |
- | ^Contexte |directory, .htaccess| | + | |
- | + | ||
- | === AuthLDAPURL === | + | |
- | ^Lien |http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authldapurl| | + | |
- | ^Description|Définit les paramètres de recherche LDAP| | + | |
- | ^Syntaxe |%%AuthLDAPUrl ldap://host:port/basedn?attribute?scope?filter [NONE|SSL|TLS|STARTTLS]%%| | + | |
- | ^Contexte |directory, .htaccess| | + | |
- | + | ||
- | === AuthLDAPBindDN === | + | |
- | ^Lien |http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authldapbinddn| | + | |
- | ^Description|Définit le compte de service pour se connecter au LDAP (lorsque l'authentification anonyme est impossible).| | + | |
- | ^Syntaxe |%%AuthLDAPBindDN distinguished-name%%| | + | |
- | ^Contexte |directory, .htaccess| | + | |
- | + | ||
- | === AuthLDAPBindPassword === | + | |
- | ^Lien |http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authldapbindpassword| | + | |
- | ^Description|Définit le mot de passe du compte de service| | + | |
- | ^Syntaxe |%%AuthLDAPBindPassword password%%| | + | |
- | ^Contexte |directory, .htaccess| | + | |
- | + | ||
- | === AuthzLDAPAuthoritative === | + | |
- | ^Lien |http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authzldapauthoritative| | + | |
- | ^Description|Permet de contrôler si d'autre module d'authentification peuvent authentifier l'utilisateur en cas d'utilisateur introuvable dans le LDAP.| | + | |
- | ^Syntaxe |%%AuthzLDAPAuthoritative on|off%%| | + | |
- | ^Contexte |directory, .htaccess| | + | |
- | + | ||
- | === Require === | + | |
- | ^Lien |http://httpd.apache.org/docs/2.2/fr/mod/core.html#require| | + | |
- | ^Description|Définit quelle personne authentifiée peut accèder à ce répertoire| | + | |
- | ^Syntaxe |Require entity-name [entity-name] ...| | + | |
- | ^Contexte |directory, .htaccess| | + | |
- | + | ||
- | Exemples : | + | |
- | * N'importe quel utilisateur valide : | + | |
- | + | ||
- | require valid-user | + | |
- | + | ||
- | * L'utilisateur matthieu : | + | |
- | + | ||
- | require matthieu | + | |
- | + | ||
- | * Le groupe "web" : | + | |
- | + | ||
- | require ldap-group cn=web,ou=groups,dc=matthieu,dc=bouthors,dc=org | + | |
- | ===== Authentification MySQL ===== | + | |
- | Attention : la méthode décrite ci dessous ne fonctionne plus avec les dernières version de apache. | + | |
- | En effet le module utilisé n'est plus maintenu. | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ==== Installation ==== | + | |
- | + | ||
- | Pour l'installation de Mysql, voir [[mysql]].\\ | + | |
- | Pour construire la base de données contenant les utilisateurs, voir [[authent_sql]]. | + | |
- | + | ||
- | Le paquet suivant est nécessaire : | + | |
- | * libapache2-auth-mysql | + | |
- | + | ||
- | Une fois installé, il suffit d'activer le module avec la commande suivante : | + | |
- | a2enmod auth_mysql | + | |
- | + | ||
- | ==== Configuration ==== | + | |
- | Voici un exemple de configuration avec l'authentification Mysql. | + | |
- | + | ||
- | Pour le descriptif des directives, voir http://www.diegonet.com/support/mod_auth_mysql.shtml | + | |
- | + | ||
- | <file> | + | |
- | # configuration authentification mysql (auth mysql) | + | |
- | Auth_MySQL_Info localhost apache ********* | + | |
- | Auth_MySQL_General_DB users | + | |
- | + | ||
- | <Directory /> | + | |
- | AllowOverride None | + | |
- | + | ||
- | Auth_MySQL_Password_Table users | + | |
- | Auth_MySQL_Group_Table groupes_apache | + | |
- | Auth_MySQL_Username_Field login | + | |
- | Auth_MySQL_Password_Field password | + | |
- | Auth_MySQL_Group_Field groupe | + | |
- | Auth_MySQL_Empty_Passwords off | + | |
- | Auth_MySQL_Encryption_Types Crypt | + | |
- | Auth_MySQL_Authoritative on | + | |
- | Auth_MySQL on | + | |
- | + | ||
- | AuthType Basic | + | |
- | AuthName Extranet_matthieu.bouthors.org | + | |
- | Require group admin | + | |
- | Order Deny,Allow | + | |
- | Deny from All | + | |
- | </Directory> | + | |
- | + | ||
- | <Directory /home/ssl> | + | |
- | Options Indexes FollowSymLinks MultiViews | + | |
- | AllowOverride None | + | |
- | Order allow,deny | + | |
- | allow from all | + | |
- | Require valid-user | + | |
- | </Directory> | + | |
- | </file> | + | |
- | + | ||
- | + | ||
- | ===== Encodage des caractères spéciaux ===== | + | |
- | Le fichier ///etc/apache2/conf.d/charset// définit le Content-Type renvoyé par Apache. | + | |
- | + | ||
- | Par défaut, il est en UTF8 : | + | |
- | <file> | + | |
- | AddDefaultCharset UTF-8 | + | |
- | </file> | + | |
- | + | ||
- | Pour configurer le serveur en ISO, il faut indiquer : | + | |
- | <file> | + | |
- | AddDefaultCharset ISO-8859-15 | + | |
- | </file> | + | |
- | + | ||
- | + | ||
- | + | ||
- | ===== Configuration de PHP ===== | + | |
- | + | ||
- | Dans ///etc/php5/apache2/php.ini// configurer la taille maximum d'upload autorisé, par exemple : | + | |
- | upload_max_filesize = 15M | + | |
- | + | ||
+ | Pour aller plus loin et configurer en détail Apache, voir les sous-parties suivantes : | ||
+ | * [[linux:serveur_web:config]] | ||
+ | * [[linux:serveur_web:ssl]] | ||
+ | * [[linux:serveur_web:auth]] | ||
Ligne 250: | Ligne 66: | ||
* http://httpd.apache.org/docs/2.2/mod/mod_authn_dbd.html | * http://httpd.apache.org/docs/2.2/mod/mod_authn_dbd.html | ||
* http://apache.webthing.com/database/ | * http://apache.webthing.com/database/ | ||
- | * http://www.diegonet.com/support/mod_auth_mysql.shtml | + | |