Apache » Historique » Version 15
Patrice Nadeau, 2015-06-13 10:10
| 1 | 3 | Patrice Nadeau | h1. Apache |
|---|---|---|---|
| 2 | 1 | Patrice Nadeau | |
| 3 | Serveur de page Web |
||
| 4 | |||
| 5 | --- |
||
| 6 | |||
| 7 | {{toc}} |
||
| 8 | |||
| 9 | 3 | Patrice Nadeau | h2. Installation |
| 10 | 1 | Patrice Nadeau | |
| 11 | > Le module _apache2-mod_php5_ n’a pas nécessairement déjà été installé. |
||
| 12 | <pre><code class="bash"> |
||
| 13 | zypper install apache2 apache2-mod_php5 |
||
| 14 | 5 | Patrice Nadeau | systemctl enable apache2.service |
| 15 | 1 | Patrice Nadeau | # Démarrer Apache : |
| 16 | 5 | Patrice Nadeau | systemctl start apache2.service |
| 17 | 1 | Patrice Nadeau | </code></pre> |
| 18 | |||
| 19 | Ouvrir dans le pare-feu : |
||
| 20 | <pre><code class="bash"> |
||
| 21 | yast firewall services add service=service:apache2 zone=EXT |
||
| 22 | </code></pre> |
||
| 23 | |||
| 24 | L’emplacement des fichier du serveur est _/srv/www/htdocs_. |
||
| 25 | |||
| 26 | 3 | Patrice Nadeau | h2. Serveurs virtuels |
| 27 | 1 | Patrice Nadeau | |
| 28 | 8 | Patrice Nadeau | h3. Redirection vers un dossier différent. |
| 29 | 6 | Patrice Nadeau | |
| 30 | 15 | Patrice Nadeau | Ex. : On veux diriger _www.domain.tld_ vers le dossier _/srv/www/htdocs/web_ et _wiki.domain.tld_ vers le dossier _/srv/www/htdocs/wiki_ |
| 31 | <pre><code class="php"> |
||
| 32 | <VirtualHost *:80> |
||
| 33 | ServerName www.domain.tld |
||
| 34 | DocumentRoot /srv/www/htdocs/web |
||
| 35 | ServerAdmin admin@domain.tld |
||
| 36 | <Directory "/srv/www/htdocs/web"> |
||
| 37 | Order allow,deny |
||
| 38 | Allow from all |
||
| 39 | </Directory> |
||
| 40 | </VirtualHost> |
||
| 41 | 1 | Patrice Nadeau | |
| 42 | 15 | Patrice Nadeau | <VirtualHost *:80> |
| 43 | ServerName wiki.domain.tld |
||
| 44 | DocumentRoot /srv/www/htdocs/wiki |
||
| 45 | ServerAdmin admin@domain.tld |
||
| 46 | <Directory "/srv/www/htdocs/wiki"> |
||
| 47 | Order allow,deny |
||
| 48 | Allow from all |
||
| 49 | </Directory> |
||
| 50 | </VirtualHost> |
||
| 51 | </code></pre> |
||
| 52 | |||
| 53 | Si le fichier _/etc/apache2/vhosts.d/vhost.conf_ n'existe pas, en créer à partir du gabarit de base |
||
| 54 | 1 | Patrice Nadeau | <pre><code class="bash"> |
| 55 | cd /etc/apache2/vhosts.d/ |
||
| 56 | cp vhost.template vhost.conf |
||
| 57 | </code></pre> |
||
| 58 | |||
| 59 | Modifier les items suivants : |
||
| 60 | * *ServerAdmin* : L'adresse de courriel de l'administrateur |
||
| 61 | 4 | Patrice Nadeau | * *ServerName* : Le FQDN(Fully Qualified Domain Name) du serveur |
| 62 | 1 | Patrice Nadeau | * *DocumentRoot* : L'emplacement des fichiers du site web |
| 63 | 7 | Patrice Nadeau | |
| 64 | h3. Redirection vers un serveur différent |
||
| 65 | |||
| 66 | 9 | Patrice Nadeau | Les modules _proxy_ et _proxy_http_ doivent être installés et actifs |
| 67 | |||
| 68 | Vérification de la liste des modules Apache |
||
| 69 | <pre><code class="bash"> |
||
| 70 | a2enmod -l |
||
| 71 | </code></pre> |
||
| 72 | |||
| 73 | 11 | Patrice Nadeau | Activation des modules s'il ne sont pas deja actifs |
| 74 | <pre><code class="bash"> |
||
| 75 | a2enmod proxy proxy_http |
||
| 76 | </code></pre> |
||
| 77 | |||
| 78 | 12 | Patrice Nadeau | Modifier le fichier _/etc/apache2/vhosts.d/vhost.conf_ |
| 79 | 13 | Patrice Nadeau | Ex. : On veux rediriger le service _service_ vers le serveur _server1_ |
| 80 | 14 | Patrice Nadeau | <pre><code class="php"> |
| 81 | 12 | Patrice Nadeau | <VirtualHost *:80> |
| 82 | ServerName service.domaine.com |
||
| 83 | ProxyPass / http://serveur1.domaine.com/ |
||
| 84 | ProxyPassReverse / http://serveur1.domaine.com/ |
||
| 85 | 13 | Patrice Nadeau | ServerAdmin admin@domaine.com |
| 86 | 12 | Patrice Nadeau | </VirtualHost> |
| 87 | 11 | Patrice Nadeau | |
| 88 | 12 | Patrice Nadeau | </code></pre> |
| 89 | 11 | Patrice Nadeau | |
| 90 | 7 | Patrice Nadeau | h3. Activation des changements |
| 91 | 1 | Patrice Nadeau | |
| 92 | Relire la configuration d'Apache |
||
| 93 | <pre><code class="bash"> |
||
| 94 | syctemsctl reload apache2 |
||
| 95 | </code></pre> |
||
| 96 | |||
| 97 | Commandes |
||
| 98 | 10 | Patrice Nadeau | * _apache2ctl -S_ : liste les serveurs virtuels |