Configurer Apache
Par mrjay42, vendredi 14 janvier 2011 à 09:46 :: Linux :: #66 :: rss
Je ne suis vraiment pas un pro de la config Apache, alors je note ici ce que j'ai fait au boulot pour gérer mes différents nom de domaine
La configuration proposée est faite sous Linux (Ubuntu)
Objectifs :
Gérer Plusieurs adresses certaines pointant vers le même répertoire d'autre pointant vers des répertoires différents
Pour ajouter un site sur votre Apache il faut faire comme suit :
- Allez dans /etc/apache2/sites-available
- Tapez "sudo vim monSiteConf"
- Il faut être root pour éditer et enregistrer une conf Apache, d'où le sudo
- Saisissez une config dans votre fichier et enregistrez-la
- ensuite tapez : sudo a2ensite monSiteConf
- Ce qui pour resultat d'ajouter un lien symbolique dans sites-enabled vers votre fichier de conf
- Pour enlever un site il faut faire a2dissite monSiteConf (en étant placé dans sites-available)
- Pensez à redémarrer Apache en faisant : sudo /etc/init.d/apache2 restart
- Quand vous redémarrez Apache, vous ne devez pas obtenir de message d'erreur...un simple "OK" doit s'affiche :)
- tapez ça : sudo vim /etc/hosts
- et rajoutez ça : 127.0.0.1 AdresseDuSite
Voici mes exemples de conf Apache :
<VirtualHost *:80> ServerAdmin admin@localhost DocumentRoot "/home/mrjay/workspace/Portail_branche_2_1" ServerName xxxxx2 ServerAlias xxxx1 </VirtualHost> <VirtualHost *:443> ServerAdmin admin@localhost DocumentRoot "/home/mrjay/workspace/Portail_branche_2_1" ServerName xxxxx1 ServerAlias xxxxx2 SSLEngine On SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key </VirtualHost>
<VirtualHost *:80> ServerAdmin admin@localhost DocumentRoot "/home/mrjay/workspace/Portail_trunk" ServerName xxxxx1 </VirtualHost> <VirtualHost *:443> ServerAdmin admin@localhost DocumentRoot "/home/mrjay/workspace/Portail_trunk" ServerName xxxxx2 SSLEngine On SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key </VirtualHost>
Dans /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also # have to change the VirtualHost statement in # /etc/apache2/sites-enabled/000-default # This is also true if you have upgraded from before 2.2.9-3 (i.e. from # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and # README.Debian.gz NameVirtualHost *:80 Listen 80 <IfModule mod_ssl.c> # If you add NameVirtualHost *:443 here, you will also have to change # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # to <VirtualHost *:443> # Server Name Indication for SSL named virtual hosts is currently not # supported by MSIE on Windows XP. Listen 443 NameVirtualHost *:443 </IfModule> <IfModule mod_gnutls.c> Listen 443 </IfModule>
Dans /etc/hosts :
127.0.0.1 xxxxxxx1 127.0.0.1 xxxxxx2 127.0.0.1 xxxxxxxx3 127.0.0.1 xxxxxxxxx4