Apache » Historique » Version 31
Patrice Nadeau, 2017-04-29 10:09
1 | 3 | Patrice Nadeau | h1. Apache |
---|---|---|---|
2 | 1 | Patrice Nadeau | |
3 | Serveur de page Web |
||
4 | |||
5 | 21 | Patrice Nadeau | > Version 2.4 |
6 | |||
7 | 1 | Patrice Nadeau | --- |
8 | |||
9 | {{toc}} |
||
10 | |||
11 | 3 | Patrice Nadeau | h2. Installation |
12 | 1 | Patrice Nadeau | |
13 | <pre><code class="bash"> |
||
14 | 29 | Patrice Nadeau | # Installation |
15 | 31 | Patrice Nadeau | zypper install apache2 |
16 | 29 | Patrice Nadeau | # Activation au démarrage |
17 | 5 | Patrice Nadeau | systemctl enable apache2.service |
18 | 1 | Patrice Nadeau | # Démarrer Apache : |
19 | 26 | Patrice Nadeau | systemctl start apache2.service |
20 | 1 | Patrice Nadeau | </code></pre> |
21 | |||
22 | Ouvrir dans le pare-feu : |
||
23 | <pre><code class="bash"> |
||
24 | yast firewall services add service=service:apache2 zone=EXT |
||
25 | </code></pre> |
||
26 | |||
27 | L’emplacement des fichier du serveur est _/srv/www/htdocs_. |
||
28 | |||
29 | h2. Modules supplémentaires |
||
30 | 31 | Patrice Nadeau | > La configuration d'Apache doit être relue lors de l'ajout d'un module |
31 | 1 | Patrice Nadeau | |
32 | 31 | Patrice Nadeau | h3. Version_module |
33 | |||
34 | Inclut dans Apache |
||
35 | 1 | Patrice Nadeau | <pre><code class="bash"> |
36 | a2enmod mod_version |
||
37 | 31 | Patrice Nadeau | </code></pre> |
38 | |||
39 | h3. PHP |
||
40 | |||
41 | Support pour PHP |
||
42 | <pre><code class="bash"> |
||
43 | zypper install apache2-mod_php5 |
||
44 | a2enmod mod_php5 |
||
45 | 30 | Patrice Nadeau | </code></pre> |
46 | |||
47 | 3 | Patrice Nadeau | h2. Serveurs virtuels |
48 | 1 | Patrice Nadeau | |
49 | 19 | Patrice Nadeau | Apache permet de rediriger les demandes d’accès vers |
50 | * différents répertoires sur le même serveur |
||
51 | * différents port |
||
52 | * un autre serveur |
||
53 | |||
54 | 17 | Patrice Nadeau | Très utile pour rediriger les requêtes à partir d'internet avec un seule adresse IP publique (NAT(Network Address Translation)). |
55 | |||
56 | |||
57 | 18 | Patrice Nadeau | Si le fichier _/etc/apache2/vhosts.d/vhost.conf_ n'existe pas, le créer à partir du gabarit de base |
58 | 17 | Patrice Nadeau | <pre><code class="bash"> |
59 | cd /etc/apache2/vhosts.d/ |
||
60 | cp vhost.template vhost.conf |
||
61 | </code></pre> |
||
62 | |||
63 | 8 | Patrice Nadeau | h3. Redirection vers un dossier différent. |
64 | 6 | Patrice Nadeau | |
65 | 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_ |
66 | 15 | Patrice Nadeau | <pre><code class="php"> |
67 | <VirtualHost *:80> |
||
68 | 16 | Patrice Nadeau | ServerName helpdesk.domain.tld |
69 | DocumentRoot /srv/www/htdocs/hepdesk |
||
70 | 15 | Patrice Nadeau | ServerAdmin admin@domain.tld |
71 | 16 | Patrice Nadeau | <Directory "/srv/www/htdocs/helpdesk"> |
72 | 25 | Patrice Nadeau | #Order allow,deny #Since Apache 2.4 |
73 | 22 | Patrice Nadeau | Require all granted |
74 | 15 | Patrice Nadeau | </Directory> |
75 | </VirtualHost> |
||
76 | |||
77 | <VirtualHost *:80> |
||
78 | ServerName wiki.domain.tld |
||
79 | DocumentRoot /srv/www/htdocs/wiki |
||
80 | ServerAdmin admin@domain.tld |
||
81 | <Directory "/srv/www/htdocs/wiki"> |
||
82 | 25 | Patrice Nadeau | #Order allow,deny # since Apache 2.4 |
83 | 22 | Patrice Nadeau | Require all granted |
84 | 1 | Patrice Nadeau | </Directory> |
85 | </VirtualHost> |
||
86 | </code></pre> |
||
87 | |||
88 | Modifier les items suivants : |
||
89 | * *ServerAdmin* : L'adresse de courriel de l'administrateur |
||
90 | 4 | Patrice Nadeau | * *ServerName* : Le FQDN(Fully Qualified Domain Name) du serveur |
91 | 1 | Patrice Nadeau | * *DocumentRoot* : L'emplacement des fichiers du site web |
92 | 7 | Patrice Nadeau | |
93 | h3. Redirection vers un serveur différent |
||
94 | |||
95 | 9 | Patrice Nadeau | Les modules _proxy_ et _proxy_http_ doivent être installés et actifs |
96 | |||
97 | Vérification de la liste des modules Apache |
||
98 | <pre><code class="bash"> |
||
99 | a2enmod -l |
||
100 | </code></pre> |
||
101 | |||
102 | 20 | Patrice Nadeau | Activation des modules s'il ne sont pas déjà actifs |
103 | 11 | Patrice Nadeau | <pre><code class="bash"> |
104 | 24 | Patrice Nadeau | a2enmod proxy |
105 | a2enmod proxy_http |
||
106 | 11 | Patrice Nadeau | </code></pre> |
107 | |||
108 | 12 | Patrice Nadeau | Modifier le fichier _/etc/apache2/vhosts.d/vhost.conf_ |
109 | 13 | Patrice Nadeau | Ex. : On veux rediriger le service _service_ vers le serveur _server1_ |
110 | 14 | Patrice Nadeau | <pre><code class="php"> |
111 | 12 | Patrice Nadeau | <VirtualHost *:80> |
112 | ServerName service.domaine.com |
||
113 | 28 | Patrice Nadeau | ProxyPreserveHost On |
114 | 12 | Patrice Nadeau | ProxyPass / http://serveur1.domaine.com/ |
115 | ProxyPassReverse / http://serveur1.domaine.com/ |
||
116 | 13 | Patrice Nadeau | ServerAdmin admin@domaine.com |
117 | 12 | Patrice Nadeau | </VirtualHost> |
118 | 11 | Patrice Nadeau | |
119 | 12 | Patrice Nadeau | </code></pre> |
120 | 11 | Patrice Nadeau | |
121 | 7 | Patrice Nadeau | h3. Activation des changements |
122 | 1 | Patrice Nadeau | |
123 | Relire la configuration d'Apache |
||
124 | <pre><code class="bash"> |
||
125 | 27 | Patrice Nadeau | systemctl reload apache2.service |
126 | 1 | Patrice Nadeau | </code></pre> |
127 | |||
128 | Commandes |
||
129 | 10 | Patrice Nadeau | * _apache2ctl -S_ : liste les serveurs virtuels |