Apache » Historique » Version 17
Patrice Nadeau, 2015-06-13 10:14
| 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 | 17 | Patrice Nadeau | Apache permet de rediriger les demandes d’accès vers différents répertoires sur le même serveur ou même vers un autre serveur. |
| 29 | Très utile pour rediriger les requêtes à partir d'internet avec un seule adresse IP publique (NAT(Network Address Translation)). |
||
| 30 | |||
| 31 | |||
| 32 | Si le fichier _/etc/apache2/vhosts.d/vhost.conf_ n'existe pas, en créer à partir du gabarit de base |
||
| 33 | <pre><code class="bash"> |
||
| 34 | cd /etc/apache2/vhosts.d/ |
||
| 35 | cp vhost.template vhost.conf |
||
| 36 | </code></pre> |
||
| 37 | |||
| 38 | 8 | Patrice Nadeau | h3. Redirection vers un dossier différent. |
| 39 | 6 | Patrice Nadeau | |
| 40 | 16 | Patrice Nadeau | Ex. : On veux diriger _helpdesk.domain.tld_ vers le dossier _/srv/www/htdocs/helpdesk_ et _wiki.domain.tld_ vers le dossier _/srv/www/htdocs/wiki_ |
| 41 | 15 | Patrice Nadeau | <pre><code class="php"> |
| 42 | <VirtualHost *:80> |
||
| 43 | 16 | Patrice Nadeau | ServerName helpdesk.domain.tld |
| 44 | DocumentRoot /srv/www/htdocs/hepdesk |
||
| 45 | 15 | Patrice Nadeau | ServerAdmin admin@domain.tld |
| 46 | 16 | Patrice Nadeau | <Directory "/srv/www/htdocs/helpdesk"> |
| 47 | 15 | Patrice Nadeau | Order allow,deny |
| 48 | Allow from all |
||
| 49 | </Directory> |
||
| 50 | </VirtualHost> |
||
| 51 | |||
| 52 | <VirtualHost *:80> |
||
| 53 | ServerName wiki.domain.tld |
||
| 54 | DocumentRoot /srv/www/htdocs/wiki |
||
| 55 | ServerAdmin admin@domain.tld |
||
| 56 | <Directory "/srv/www/htdocs/wiki"> |
||
| 57 | Order allow,deny |
||
| 58 | 1 | Patrice Nadeau | Allow from all |
| 59 | </Directory> |
||
| 60 | </VirtualHost> |
||
| 61 | </code></pre> |
||
| 62 | |||
| 63 | Modifier les items suivants : |
||
| 64 | * *ServerAdmin* : L'adresse de courriel de l'administrateur |
||
| 65 | 4 | Patrice Nadeau | * *ServerName* : Le FQDN(Fully Qualified Domain Name) du serveur |
| 66 | 1 | Patrice Nadeau | * *DocumentRoot* : L'emplacement des fichiers du site web |
| 67 | 7 | Patrice Nadeau | |
| 68 | h3. Redirection vers un serveur différent |
||
| 69 | |||
| 70 | 9 | Patrice Nadeau | Les modules _proxy_ et _proxy_http_ doivent être installés et actifs |
| 71 | |||
| 72 | Vérification de la liste des modules Apache |
||
| 73 | <pre><code class="bash"> |
||
| 74 | a2enmod -l |
||
| 75 | </code></pre> |
||
| 76 | |||
| 77 | 11 | Patrice Nadeau | Activation des modules s'il ne sont pas deja actifs |
| 78 | <pre><code class="bash"> |
||
| 79 | a2enmod proxy proxy_http |
||
| 80 | </code></pre> |
||
| 81 | |||
| 82 | 12 | Patrice Nadeau | Modifier le fichier _/etc/apache2/vhosts.d/vhost.conf_ |
| 83 | 13 | Patrice Nadeau | Ex. : On veux rediriger le service _service_ vers le serveur _server1_ |
| 84 | 14 | Patrice Nadeau | <pre><code class="php"> |
| 85 | 12 | Patrice Nadeau | <VirtualHost *:80> |
| 86 | ServerName service.domaine.com |
||
| 87 | ProxyPass / http://serveur1.domaine.com/ |
||
| 88 | ProxyPassReverse / http://serveur1.domaine.com/ |
||
| 89 | 13 | Patrice Nadeau | ServerAdmin admin@domaine.com |
| 90 | 12 | Patrice Nadeau | </VirtualHost> |
| 91 | 11 | Patrice Nadeau | |
| 92 | 12 | Patrice Nadeau | </code></pre> |
| 93 | 11 | Patrice Nadeau | |
| 94 | 7 | Patrice Nadeau | h3. Activation des changements |
| 95 | 1 | Patrice Nadeau | |
| 96 | Relire la configuration d'Apache |
||
| 97 | <pre><code class="bash"> |
||
| 98 | syctemsctl reload apache2 |
||
| 99 | </code></pre> |
||
| 100 | |||
| 101 | Commandes |
||
| 102 | 10 | Patrice Nadeau | * _apache2ctl -S_ : liste les serveurs virtuels |