Différences

Cette page vous donne les différences entre la révision choisie et la version actuelle de la page.

Lien vers cette vue

linux:serveur_web [2008/02/29 17:20]
127.0.0.1 modification externe
linux:serveur_web [2011/12/01 23:37] (Version actuelle)
matthieu [Links]
Ligne 1: Ligne 1:
-====== Serveur Web ======+{{tag>fr fr:linux fr:serveur fr: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.
  
-Cette page a pour but de décrire l'installation et la configuration de Apache2 avec PHP sur le serveur [[Bender]].+Cette page a pour but de décrire l'installation et la configuration de Apache2 avec PHP.
  
  
  
-===== Objectifs ===== 
-Ce serveur web est constitué de : 
-  * une partie publique accessible à tous 
-  * une partie privée chiffrée et authentifiée sur SQL découpée en deux : 
-    * l'accès restreint à des informations suivants des groupes d'utilisateurs 
-    * l'administration du site réservée aux administrateurs 
- 
-Cette configuration sert ensuite de base pour l'ajout des services web supplémentaires comme par exemple : 
-  * [[webmail]] 
-  * [[Dokuwiki]] 
-  * [[cacti]] 
-  * [[phpmyadmin]] 
-  * [[phpldapadmin]] 
-  * [[Jinzora]] 
-... 
  
  
Ligne 26: Ligne 12:
 ===== Installation ===== ===== Installation =====
 Sous debian, il suffit d'ajouter les paquets : Sous debian, il suffit d'ajouter les paquets :
-  * apache ou apache2 +  * apache2 
-  * PHP4 ou PHP5+  * PHP5
  
-Personnellement j'utilise apache2 et PHP5. apache est installé en mode préfork car le mode threaded n'est pas compatible php.+Apache est installé en mode préfork car le mode threaded n'est pas compatible php.
  
  
  
-===== 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 58: Ligne 44:
 </code> </code>
  
-Les paragraphes suivants décrivent les directives les plus utilisées dans la configuration d'un site web. +===== Configuration avancée =====
- +
-==== Inclusion de fichiers ==== +
- +
-=== Include === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/core.html#include| +
-^Description|Inclue un autre fichier ou les fichiers d'un répertoire| +
-^Syntaxe    |%%Include file-path|directory-path%%| +
-^Contexte   |server config, virtual host, directory| +
- +
-==== Scructures ==== +
- +
-=== NameVirtualHost === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/core.html#namevirtualhost| +
-^Description|Décrit quelles IP hébergent des virtual host.| +
-^Syntaxe    |NameVirtualHost addr[:port]| +
-^Contexte   |server config| +
- +
-=== <VirtualHost> === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/core.html#virtualhost| +
-^Description|Définit une IP de virtual host| +
-^Syntaxe    |<VirtualHost addr[:port] [addr[:port]] ...> ... </VirtualHost>| +
-^Contexte   |server config| +
- +
-=== <Directory> === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/core.html#directory| +
-^Description|Décrit un ensemble de directive à appliquer à un répertoire par rapport au système de fichier.| +
-^Syntaxe    |NameVirtualHost addr[:port]| +
-^Contexte   |server config, virtual host| +
- +
-=== <Location> === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/core.html#location| +
-^Description|Décrit un ensemble de directive à appliquer sur les url correspondantes.| +
-^Syntaxe    |<Location URL-path%%|%%URL> ... </Location>| +
-^Contexte   |server config, virtual host| +
- +
-=== DocumentRoot === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/core.html#documentroot| +
-^Description|Indique le répertoire racine| +
-^Syntaxe    |DocumentRoot directory-path| +
-^Contexte   |server config, virtual host| +
- +
-==== Fonctionnalités par répertoire ==== +
- +
-=== Options === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/core.html#options| +
-^Description|Définit les fonctionnalités pour un répertoire particulier| +
-^Syntaxe    |%%Options [+|-]option [[+|-]option] ...%%| +
-^Contexte   |server config, virtual host, directory, .htaccess| +
- +
-Liste des options +
-^None                |Aucune| +
-^All                 |Tout sauf MultiViews| +
-^ExecCGI             |Autorise l'exécution de CGI| +
-^FollowSymLinks      |Suit les liens symbolique\\ La directive directory ne s'applique qu'au répertoire initial.\\ La cible doit être lisible par Apache.\\ cette directive ne s'applique par aux <Localtion>| +
-^Includes            |Autorise les Includes| +
-^IncludesNOEXEC      |Autorise les Includes mais désactive les fonctions #exec cmd and #exec cgi| +
-^Indexes             |Génère un listing des répertoires| +
-^MultiViews          |Autorise l'utilisation de mod_negociation| +
-^SymLinksIfOwnerMatch|Identique à FollowSymlinks mais ne suit que les liens ayant le même propriétaire que la cible| +
- +
-=== AllowOverride === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/core.html#allowoverride| +
-^Description|Définit les directives utilisables dans les fichiers .htaccess| +
-^Syntaxe    |%%AllowOverride All|None|directive-type [directive-type] ...%%| +
-^Contexte   |directory| +
- +
-==== Alias et redirection ==== +
- +
-=== Alias === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/mod_alias.html#alias| +
-^Description|Définit le répertoire associé à une URL| +
-^Syntaxe    |%%Alias URL-path file-path|directory-path%%| +
-^Contexte   |server config, virtual host| +
- +
-=== ScriptAlias === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/mod_alias.html#scriptalias| +
-^Description|Identique à Alias mais indique que la cible est un script CGI| +
-^Syntaxe    |ScriptAlias URL-path file-path|directory-path| +
-^Contexte   |server config, virtual host| +
- +
-=== Redirect === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/mod_alias.html#redirect| +
-^Description|Redirige un client d'une URL vers une autre. Redirige également toutes les sous URL| +
-^Syntaxe    |Redirect [status] URL-path URL| +
-^Contexte   |server config, virtual host, directory, .htaccess| +
- +
-=== RedirectMatch === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/mod_alias.html#redirectmatch| +
-^Description|Redirige les URL correspondant à une expression régulière| +
-^Syntaxe    |RedirectMatch [status] regex URL| +
-^Contexte   |server config, virtual host, directory, .htaccess| +
- +
- +
-==== Gestion des accès ==== +
- +
-=== Allow === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#allow| +
-^Description|Définit les autorisations d'accès par IP, DNS ou variable| +
-^Syntaxe    |%% Allow from all|host|env=env-variable [host|env=env-variable] ...%%| +
-^Contexte   |directory, .htaccess| +
- +
-=== Deny === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#deny| +
-^Description|Définit les interdictions d'accès par IP, DNS ou variable| +
-^Syntaxe    |%%Deny from all|host|env=env-variable [host|env=env-variable] ...%%| +
-^Contexte   |directory, .htaccess| +
- +
-=== Order === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order| +
-^Description|Définit la priorité entre les règles d'accès et d'interdiction\\ Si une requête match Allow et Deny :\\ - Allow,Deny interdit la requête\\ - Deny,Allow autorise la requête| +
-^Syntaxe    |Order ordering| +
-^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| +
- +
- +
-==== Personnalisation ==== +
-=== ServerAdmin === +
-^Lien       |http://httpd.apache.org/docs/2.2/fr/mod/core.html#serveradmin| +
-^Description|Définit l'adresse email indiquée dans les messages d'erreur| +
-^Syntaxe    |ServerAdmin email-address%%|%%URL| +
-^Contexte   |server config, virtual host| +
- +
-=== ServerSignature === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/core.html#serversignature| +
-^Description|Définit la signature ajoutée aux documents générés par le serveur| +
-^Syntaxe    |%%ServerSignature On|Off|EMail%%| +
-^Contexte   |server config, virtual host, directory, .htaccess| +
- +
- +
- +
-==== Logs ==== +
- +
- +
-=== ErrorLog === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/core.html#errorlog| +
-^Description|Définit où les logs d'erreur sont envoyées| +
-^Syntaxe    |%%ErrorLog file-path|syslog[:facility]%%| +
-^Contexte   |server config, virtual host| +
- +
-=== LogLevel === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/core.html#loglevel| +
-^Description|Définit le niveau de verbosité| +
-^Syntaxe    |LogLevel level| +
-^Contexte   |server config, virtual host| +
- +
-=== CustomLog === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#customlog| +
-^Description|Définit le nom du fichier de log et son format| +
-^Syntaxe    |%%CustomLog file|pipe format|nickname [env=[!]environment-variable]%%| +
-^Contexte   |server config, virtual host| +
- +
- +
- +
- +
- +
- +
-===== Configuration de l'HTTPS ===== +
-Cette partie décrit l'activation de l'HTTPS dans Apache2. +
- +
- +
-==== Création du certificat ==== +
- +
-Pour générer le certificat, voir [[Openssl]]. +
- +
-Copier ensuite la clé privée ainsi que le certificat dans un fichier pem et le placer par exemple dans ///etc/apache2/ssl///. +
- +
- +
-==== Ouverture des ports ==== +
-Afin d'activer l'HTTPS, il faut que apache écoute le port 443. Pour cela il suffit de l'ajouter au fichier ///etc/apache2/ports.conf// : +
-<file> +
-Listen 80 +
-Listen 443 +
-</file> +
- +
- +
-==== Activation du module ==== +
-Il faut ensuite activer le module ssl : +
- +
-<code> +
-bender:/etc/apache2# a2enmod ssl +
-Module ssl installed; run /etc/init.d/apache2 force-reload to enable. +
-bender:/etc/apache2# /etc/init.d/apache2 force-reload +
-Forcing reload of web server (apache2)... waiting . +
-bender:/etc/apache2# +
-</code> +
- +
- +
-==== Configuration du ssl ==== +
-Pour finir, il faut configurer un virtual host avec le moteur SSL activé. +
- +
-Exemple de configuration : +
-<file> +
-NameVirtualHost *:443 +
-<VirtualHost *:443> +
-        SSLEngine on +
-        SSLCertificateFile /etc/apache2/ssl/mat.homeftp.org.pem +
- +
-        ServerAdmin webmaster@localhost +
- +
-        DocumentRoot /var/www/ +
-        <Directory /> +
-                Options FollowSymLinks +
-                AllowOverride None +
-        </Directory> +
-        <Directory /var/www/> +
-                Options Indexes FollowSymLinks MultiViews +
-                AllowOverride None +
-                Order allow,deny +
-                allow from all +
-                # This directive allows us to have apache2's default start page +
-                # in /apache2-default/, but still have / go to the right place +
-                RedirectMatch ^/$ /apache2-default/ +
-        </Directory> +
- +
-        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ +
-        <Directory "/usr/lib/cgi-bin"> +
-                AllowOverride None +
-                Options ExecCGI -MultiViews +SymLinksIfOwnerMatch +
-                Order allow,deny +
-                Allow from all +
-        </Directory> +
- +
-        ErrorLog /var/log/apache2/error.log +
- +
-        # Possible values include: debug, info, notice, warn, error, crit, +
-        # alert, emerg. +
-        LogLevel warn +
- +
-        CustomLog /var/log/apache2/access.log combined +
-        ServerSignature On +
- +
-    Alias /doc/ "/usr/share/doc/" +
-    <Directory "/usr/share/doc/"> +
-        Options Indexes MultiViews FollowSymLinks +
-        AllowOverride None +
-        Order deny,allow +
-        Deny from all +
-        Allow from 127.0.0.0/255.0.0.0 ::1/128 +
-    </Directory> +
- +
-</VirtualHost> +
-</file> +
- +
-Voici les principales directives pour le module SSL : +
- +
-=== SSLEngine === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslengine| +
-^Description|Active ou désactive me moteur SSL| +
-^Syntaxe    |%%SSLEngine on|off|optional%%| +
-^Contexte   |server config, virtual host| +
- +
-=== SSLCertificateFile === +
-^Lien       |http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslcertificatefile| +
-^Description|Indique le fichier contenant la clé et le certificat| +
-^Syntaxe    |SSLCertificateKeyFile file-path| +
-^Contexte   |server config, virtual host| +
- +
- +
- +
- +
-===== 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 516: Ligne 61:
  
 ===== Links ===== ===== Links =====
-  * [[start]] 
-  * [[Bender]] 
   * http://www.apache.org   * http://www.apache.org
   * http://httpd.apache.org/docs/2.2/   * http://httpd.apache.org/docs/2.2/
Ligne 523: 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+
  
  
  
linux/serveur_web.1204302047.txt.gz · Dernière modification: 2011/01/08 13:17 (modification externe)
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki