-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathapache2.xml
More file actions
2727 lines (2647 loc) · 99.1 KB
/
apache2.xml
File metadata and controls
2727 lines (2647 loc) · 99.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0"?>
<!DOCTYPE chapter [
<!ENTITY % entities SYSTEM "generic-entities.ent">
%entities;
]>
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="cha-apache2">
<title>The Apache HTTP Server</title>
<info>
<meta name="description">Learn how to install, configure, and operate the popular Apache Web Server, which includes version 2.4</meta>
<abstract>
<para>
According to the survey from <link xlink:href="http://www.netcraft.com/"/>,
the Apache HTTP Server (Apache) is the world's most widely-used Web server.
Developed by the Apache Software Foundation
(<link xlink:href="http://www.apache.org/"/>), it is available for most
operating systems. &productnamereg; includes Apache version 2.4. In this
chapter, learn how to install, configure and set up a Web server; how to
use SSL, CGI, and additional modules; and how to troubleshoot Apache.
</para>
</abstract>
<dm:docmanager xmlns:dm="urn:x-suse:ns:docmanager">
<dm:bugtracker/>
<dm:translation>yes</dm:translation>
</dm:docmanager>
<revhistory xml:id="rh-cha-apache2">
<revision>
<date>2026-04-09</date>
<revdescription>
<para/>
</revdescription>
</revision>
</revhistory>
</info>
<sect1 xml:id="sec-apache2-quickstart">
<title>Quick Start</title>
<para>
With this section, quickly set up and start Apache. You must be &rootuser;
to install and configure Apache.
</para>
<sect2 xml:id="sec-apache-quickstart-requirements">
<title>Requirements</title>
<para>
Make sure the following requirements are met before trying to set up the
Apache Web server:
</para>
<orderedlist spacing="normal">
<listitem>
<para>
The machine's network is configured properly. For more information about
this topic, refer to <xref linkend="cha-basicnet"/>.
</para>
</listitem>
<listitem>
<para>
The machine's exact system time is maintained by synchronizing with a
time server. This is necessary because parts of the HTTP protocol depend
on the correct time. See <xref linkend="cha-netz-xntp"/> to learn more
about this topic.
</para>
</listitem>
<listitem>
<para>
The latest security updates are installed. If in doubt, run a &yast;
Online Update.
</para>
</listitem>
<listitem>
<para>
The default Web server port (<literal>80</literal>) is opened in the
firewall. For this, configure the &susefirewall; to allow the service
<guimenu>HTTP Server</guimenu> in the external zone. This can be done
using &yast;. See <xref linkend="sec-security-firewall-SuSE-yast"/> for
details.
</para>
</listitem>
</orderedlist>
</sect2>
<sect2 xml:id="sec-apache2-quickstart-installation">
<title>Installation</title>
<para>
Apache on &productname; is not installed by default. To install it with a
standard, predefined configuration that runs <quote>out of the box</quote>,
proceed as follows:
</para>
<procedure>
<title>Installing Apache with the Default Configuration</title>
<step>
<para>
Start &yast; and select <menuchoice> <guimenu>Software</guimenu>
<guimenu>Software Management</guimenu> </menuchoice>.
</para>
</step>
<step>
<para>
Choose <menuchoice> <guimenu>View</guimenu> <guimenu>Patterns</guimenu>
</menuchoice> and select <guimenu>Web and LAMP Server</guimenu>.
</para>
</step>
<step>
<para>
Confirm the installation of the dependent packages to finish the
installation process.
</para>
</step>
</procedure>
</sect2>
<sect2 xml:id="sect-apache-quickstart-start">
<title>Start</title>
<para>
You can start Apache automatically at boot time or start it manually.
</para>
<para>
To make sure that Apache is automatically started during boot in the
targets <literal>multi-user.target</literal> and
<literal>graphical.target</literal>, execute the following command:
</para>
<screen>&prompt.root;systemctl enable apache2</screen>
<para>
<remark>taroth 2014-02-11: commenting the following procedure as it is unsure
how to enable a service for certain targets with YaST Services Manager,
filed bnc# 863333 for it
UPDATE tbazant 2015-08-20: still not clear, leaving commented out
</remark>
</para>
<para>
For more information about the systemd targets in &productname; and a
description of the &yast; <guimenu>&ycc_runlevel;</guimenu>, refer to
<xref linkend="sec-boot-runlevel-edit"/>.
</para>
<para>
To manually start Apache using the shell, run <command>systemctl start
apache2</command>.
</para>
<procedure>
<title>Checking if Apache is Running</title>
<para>
If you do not receive error messages when starting Apache, this usually
indicates that the Web server is running. To test this:
</para>
<step>
<para>
Start a browser and open <uri>http://localhost/</uri>.
</para>
<para>
If Apache is up and running, you get a test page stating <quote>It
works!</quote>.
</para>
</step>
<step>
<para>
If you do not see this page, refer to
<xref linkend="sec-apache2-troubleeshooting"/>.
</para>
</step>
</procedure>
<para>
Now that the Web server is running, you can add your own documents, adjust
the configuration according to your needs, or add functionality by
installing modules.
</para>
</sect2>
</sect1>
<sect1 xml:id="sec-apache2-configuration">
<title>Configuring Apache</title>
<para>
&productname; offers two configuration options:
</para>
<itemizedlist mark="bullet" spacing="normal">
<listitem>
<para>
<xref linkend="sec-apache2-configuration-manually" xrefstyle="select:title"/>
</para>
</listitem>
<listitem>
<para>
<xref linkend="sec-apache2-configuration-yast" xrefstyle="select:title"/>
</para>
</listitem>
</itemizedlist>
<para>
Manual configuration offers a higher level of detail, but lacks the
convenience of the &yast; GUI.
</para>
<important>
<title>Reload or Restart Apache after Configuration Changes</title>
<para>
Most configuration changes require a reload (some also a restart) of Apache
to take effect. Manually reload Apache with <command>systemctl reload
apache2</command> or use one of the restart options as described in
<xref linkend="sec-apache2-start-stop"/>.
</para>
<para>
If you configure Apache with &yast;, this can be taken care of
automatically if you set <guimenu>HTTP Service</guimenu> to
<guimenu>Enabled</guimenu> as described in
<xref linkend="sec-apache2-configuration-yast-server-configuration"/>.
</para>
</important>
<sect2 xml:id="sec-apache2-configuration-manually-configfiles">
<title>Apache Configuration Files</title>
<para>
This section gives an overview of the Apache configuration files. If you
use &yast; for configuration, you do not need to touch these
files—however, the information might be useful for you if you want to
switch to manual configuration later on.
</para>
<para>
Apache configuration files can be found in two different locations:
</para>
<itemizedlist mark="bullet" spacing="normal">
<listitem>
<para>
<xref linkend="sec-apache2-configuration-manually-configfiles-etc-sysconfig-apache2" xrefstyle="select:title"/>
</para>
</listitem>
<listitem>
<para>
<xref linkend="sec-apache2-configuration-manually-configfiles-etc-apache2" xrefstyle="select:title"/>
</para>
</listitem>
</itemizedlist>
<sect3 xml:id="sec-apache2-configuration-manually-configfiles-etc-sysconfig-apache2">
<title><filename>/etc/sysconfig/apache2</filename></title>
<para>
<filename>/etc/sysconfig/apache2</filename> controls some global settings
of Apache, like modules to load, additional configuration files to
include, flags with which the server should be started, and flags that
should be added to the command line. Every configuration option in this
file is extensively documented and therefore not mentioned here. For a
general-purpose Web server, the settings in
<filename>/etc/sysconfig/apache2</filename> should be sufficient for any
configuration needs.
</para>
</sect3>
<sect3 xml:id="sec-apache2-configuration-manually-configfiles-etc-apache2">
<title><filename>/etc/apache2/</filename></title>
<para>
<filename>/etc/apache2/</filename> hosts all configuration files for
Apache. In the following, the purpose of each file is explained. Each file
includes several configuration options (also called
<emphasis>directives</emphasis>). Every configuration option in these
files is extensively documented and therefore not mentioned here.
</para>
<para>
The Apache configuration files are organized as follows:
</para>
<screen>/etc/apache2/
|
|- charset.conv
|- conf.d/
| |
| |- *.conf
|
|- default-server.conf
|- errors.conf
|- httpd.conf
|- listen.conf
|- magic
|- mime.types
|- mod_*.conf
|- server-tuning.conf
|- ssl.*
|- ssl-global.conf
|- sysconfig.d
| |
| |- global.conf
| |- include.conf
| |- loadmodule.conf . .
|
|- uid.conf
|- vhosts.d
| |- *.conf</screen>
<variablelist>
<title>Apache Configuration Files in /etc/apache2/</title>
<varlistentry>
<term><filename>charset.conv</filename>
</term>
<listitem>
<para>
Specifies which character sets to use for different languages. Do not
edit this file.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>conf.d/*.conf</filename>
</term>
<listitem>
<para>
Configuration files added by other modules. These configuration files
can be included into your virtual host configuration where needed. See
<filename>vhosts.d/vhost.template</filename> for examples. By doing so,
you can provide different module sets for different virtual hosts.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>default-server.conf</filename>
</term>
<listitem>
<para>
Global configuration for all virtual hosts with reasonable defaults.
Instead of changing the values, overwrite them with a virtual host
configuration.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>errors.conf</filename>
</term>
<listitem>
<para>
Defines how Apache responds to errors. To customize these messages for
all virtual hosts, edit this file. Otherwise overwrite these directives
in your virtual host configurations.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>httpd.conf</filename>
</term>
<listitem>
<para>
The main Apache server configuration file. Avoid changing this file. It
primarily contains include statements and global settings. Overwrite
global settings in the pertinent configuration files listed here.
Change host-specific settings (such as document root) in your virtual
host configuration.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>listen.conf</filename>
</term>
<listitem>
<para>
Binds Apache to specific IP addresses and ports. Name-based virtual
hosting is also configured here. For details, see
<xref linkend="sec-apache2-configuration-manually-vhost-named-vhosts"/>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>magic</filename>
</term>
<listitem>
<para>
Data for the mime_magic module that helps Apache automatically
determine the MIME type of an unknown file. Do not change this file.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>mime.types</filename>
</term>
<listitem>
<para>
MIME types known by the system (this actually is a link to
<filename>/etc/mime.types</filename>). Do not edit this file. If you
need to add MIME types not listed here, add them to
<filename>mod_mime-defaults.conf</filename>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>mod_*.conf</filename>
</term>
<listitem>
<para>
Configuration files for the modules that are installed by default.
Refer to <xref linkend="sec-apache2-modules"/> for details. Note that
configuration files for optional modules reside in the directory
<filename>conf.d</filename>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>server-tuning.conf</filename>
</term>
<listitem>
<para>
Contains configuration directives for the different MPMs (see
<xref linkend="sec-apache2-modules-mpm"/>) and general configuration
options that control Apache's performance. Properly test your Web
server when making changes here.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>ssl-global.conf</filename> and <filename>ssl.*</filename>
</term>
<listitem>
<para>
Global SSL configuration and SSL certificate data. Refer to
<xref linkend="sec-apache2-ssl"/> for details.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>sysconfig.d/*.conf</filename>
</term>
<listitem>
<para>
Configuration files automatically generated from
<filename>/etc/sysconfig/apache2</filename>. Do not change any of these
files—edit <filename>/etc/sysconfig/apache2</filename> instead.
Do not put other configuration files in this directory.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>uid.conf</filename>
</term>
<listitem>
<para>
Specifies under which user and group ID Apache runs. Do not change this
file.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>vhosts.d/*.conf</filename>
</term>
<listitem>
<para>
Your virtual host configuration should be located here. The directory
contains template files for virtual hosts with and without SSL. Every
file in this directory ending with <filename>.conf</filename> is
automatically included in the Apache configuration. Refer to
<xref linkend="sec-apache2-configuration-manually-vhost"/> for details.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect3>
</sect2>
<sect2 xml:id="sec-apache2-configuration-manually">
<title>Configuring Apache Manually</title>
<para>
Configuring Apache manually involves editing plain text configuration files
as user <systemitem class="username">root</systemitem>.
</para>
<sect3 xml:id="sec-apache2-configuration-manually-vhost">
<title>Virtual Host Configuration</title>
<para>
The term <emphasis>virtual host</emphasis> refers to Apache's ability to
serve multiple universal resource identifiers (URIs) from the same
physical machine. This means that several domains, such as &wwwname; and
&wwwname1;, are run by a single Web server on one physical machine.
</para>
<para>
It is common practice to use virtual hosts to save administrative effort
(only a single Web server needs to be maintained) and hardware expenses
(each domain does not require a dedicated server). Virtual hosts can be
name based, IP based, or port based.
</para>
<para>
To list all existing virtual hosts, use the command
<command>apache2ctl</command> <option>-S</option>. This outputs a list
showing the default server and all virtual hosts together with their IP
addresses and listening ports. Furthermore, the list also contains an
entry for each virtual host showing its location in the configuration
files.
</para>
<para>
Virtual hosts can be configured via &yast; as described in
<xref linkend="sec-apache2-configuration-yast-wizard-virtual-hosts"/> or
by manually editing a configuration file. By default, Apache in
&productname; is prepared for one configuration file per virtual host in
<filename>/etc/apache2/vhosts.d/</filename>. All files in this directory
with the extension <filename>.conf</filename> are automatically included
to the configuration. A basic template for a virtual host is provided in
this directory (<filename>vhost.template</filename> or
<filename>vhost-ssl.template</filename> for a virtual host with SSL
support).
</para>
<tip>
<title>Always Create a Virtual Host Configuration</title>
<para>
It is recommended to always create a virtual host configuration file,
even if your Web server only hosts one domain. By doing so, you not only
have the domain-specific configuration in one file, but you can always
fall back to a working basic configuration by simply moving, deleting, or
renaming the configuration file for the virtual host. For the same
reason, you should also create separate configuration files for each
virtual host.
</para>
<para>
When using name-based virtual hosts it is recommended to set up a default
configuration that will be used when a domain name does not match a
virtual host configuration. The default virtual host is the one whose
configuration is loaded first. Since the order of the configuration files
is determined by file name, start the file name of the default virtual
host configuration with an underscore character (<literal>_</literal>) to
make sure it is loaded first (for example:
<filename>_default_vhost.conf</filename>).
</para>
</tip>
<para>
The
<systemitem><VirtualHost></systemitem><systemitem></VirtualHost></systemitem>
block holds the information that applies to a particular domain. When
Apache receives a client request for a defined virtual host, it uses the
directives enclosed in this section. Almost all directives can be used in
a virtual host context. See
<link xlink:href="http://httpd.apache.org/docs/2.4/mod/quickreference.html"/>
for further information about Apache's configuration directives.
</para>
<sect4 xml:id="sec-apache2-configuration-manually-vhost-named-vhosts">
<title>Name-Based Virtual Hosts</title>
<para>
With name-based virtual hosts, more than one Web site is served per IP
address. Apache uses the host field in the HTTP header that is sent by
the client to connect the request to a matching
<systemitem>ServerName</systemitem> entry of one of the virtual host
declarations. If no matching <systemitem>ServerName</systemitem> is
found, the first specified virtual host is used as a default.
</para>
<para>
The first step is to create a <literal><VirtualHost></literal>
block for each different name-based host that you want to serve. Inside
each <literal><VirtualHost></literal> block, you will need at
minimum a <literal>ServerName</literal> directive to designate which host
is served and a <literal>DocumentRoot</literal> directive to show where
in the file system the content for that host resides.
</para>
<example xml:id="ex-apache2-virtual-hosts-name-based">
<title>Basic Examples of Name-Based <systemitem>VirtualHost</systemitem> Entries</title>
<screen><VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.example.com
ServerAlias example.com
DocumentRoot /srv/www/htdocs/domain
</VirtualHost>
<VirtualHost *:80>
ServerName other.example.com
DocumentRoot /srv/www/htdocs/otherdomain
</VirtualHost></screen>
</example>
<para>
The opening <systemitem>VirtualHost</systemitem> tag takes the IP address
(or fully qualified domain name) as an argument in a name-based virtual
host configuration. A port number directive is optional.
</para>
<para>
The wild card <emphasis>*</emphasis> is also allowed as a substitute for
the IP address. When using IPv6 addresses, the address must be included
in square brackets.
</para>
<example xml:id="ex-apache-directives-virtualhost-name-based">
<title>Name-Based <systemitem>VirtualHost</systemitem> Directives</title>
<screen><VirtualHost &wwwip;:80>
...
</VirtualHost>
<VirtualHost &wwwip;>
...
</VirtualHost>
<VirtualHost *:80>
...
</VirtualHost>
<VirtualHost *>
...
</VirtualHost>
<VirtualHost [&wwwipv6;]>
...
</VirtualHost></screen>
</example>
</sect4>
<sect4 xml:id="sec-apache2-configuration-manually-vhost-ip-vhosts">
<title>IP-Based Virtual Hosts</title>
<para>
This alternative virtual host configuration requires the setup of
multiple IPs for a machine. One instance of Apache hosts several domains,
each of which is assigned a different IP.
</para>
<para>
The physical server must have one IP address for each IP-based virtual
host. If the machine does not have multiple network cards, virtual
network interfaces (IP aliasing) can also be used.
</para>
<para>
The following example shows Apache running on a machine with the IP
<systemitem class="ipaddress">&wwwip;</systemitem>, hosting two domains
on the additional IPs <systemitem class="ipaddress">&wwwip1;</systemitem>
and <systemitem class="ipaddress">&wwwip2;</systemitem>. A separate
<systemitem>VirtualHost</systemitem> block is needed for every virtual
server.
</para>
<example xml:id="ex-apache-directives-virtualhost-ip-based">
<title>IP-Based <systemitem>VirtualHost</systemitem> Directives</title>
<screen><VirtualHost &wwwip1;>
...
</VirtualHost>
<VirtualHost &wwwip2;>
...
</VirtualHost></screen>
</example>
<para>
Here, <systemitem>VirtualHost</systemitem> directives are only specified
for interfaces other than <systemitem>&wwwip;</systemitem>. When a
<systemitem>Listen</systemitem> directive is also configured for
<systemitem>&wwwip;</systemitem>, a separate IP-based virtual host must
be created to answer HTTP requests to that interface—otherwise the
directives found in the default server configuration
(<filename>/etc/apache2/default-server.conf</filename>) are applied.
</para>
</sect4>
<sect4 xml:id="sec-apache2-configuration-manually-vhost-basic-configuration">
<title>Basic Virtual Host Configuration</title>
<para>
At least the following directives should be in each virtual host
configuration to set up a virtual host. See
<filename>/etc/apache2/vhosts.d/vhost.template</filename> for more
options.
</para>
<variablelist>
<varlistentry>
<term><systemitem>ServerName</systemitem>
</term>
<listitem>
<para>
The fully qualified domain name under which the host should be
addressed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><systemitem>DocumentRoot</systemitem>
</term>
<listitem>
<para>
Path to the directory from which Apache should serve files for this
host. For security reasons, access to the entire file system is
forbidden by default, so you must explicitly unlock this directory
within a <systemitem>Directory</systemitem> container.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><systemitem>ServerAdmin</systemitem>
</term>
<listitem>
<para>
E-mail address of the server administrator. This address is, for
example, shown on error pages Apache creates.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><systemitem>ErrorLog</systemitem>
</term>
<listitem>
<para>
The error log file for this virtual host. Although it is not necessary
to create separate error log files for each virtual host, it is common
practice to do so, because it makes the debugging of errors much
easier. <filename>/var/log/apache2/</filename> is the default
directory for Apache's log files.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><systemitem>CustomLog</systemitem>
</term>
<listitem>
<para>
The access log file for this virtual host. Although it is not
necessary to create separate access log files for each virtual host,
it is common practice to do so, because it allows the separate
analysis of access statistics for each host.
<filename>/var/log/apache2/</filename> is the default directory for
Apache's log files.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
As mentioned above, access to the whole file system is forbidden by
default for security reasons. Therefore, explicitly unlock the
directories in which you have placed the files Apache should
serve—for example the <systemitem>DocumentRoot</systemitem>:
</para>
<screen><Directory "/srv/www/&wwwname;/htdocs">
Require all granted
</Directory></screen>
<note>
<title><literal>Require all granted</literal></title>
<para>
In previous versions of Apache, the statement <literal>Require all
granted</literal> was expressed as:
</para>
<screen>Order allow,deny
Allow from all</screen>
<para>
This old syntax is still supported by the
<literal>mod_access_compat</literal> module.
</para>
</note>
<para>
The complete configuration file looks like this:
</para>
<example xml:id="ex-apache-directives-virtualhost-basic-configuration">
<title>Basic <systemitem>VirtualHost</systemitem> Configuration</title>
<screen><VirtualHost &wwwip;>
ServerName &wwwname;
DocumentRoot /srv/www/&wwwname;/htdocs
ServerAdmin webmaster@&exampledomain;
ErrorLog /var/log/apache2/&wwwname;_log
CustomLog /var/log/apache2/&wwwname;-access_log common
<Directory "/srv/www/&wwwname;/htdocs">
Require all granted
</Directory>
</VirtualHost></screen>
</example>
</sect4>
</sect3>
</sect2>
<!-- YaST configuration -->
<xi:include href="apache2_yast_i.xml"/>
<!-- /YaST configuration -->
</sect1>
<sect1 xml:id="sec-apache2-start-stop">
<title>Starting and Stopping Apache</title>
<remark>taroth 2014-02-11: @file-maintainer: please give the following a
thorough check - so far I only replaced the rc* commands by the systemctl
(and where those are not available, by apachectl commands as advised by
crrodriguez), but the descriptions might need adjustment and some commands
are probably no longer around, therefore I commented them</remark>
<para>
If configured with &yast; as described in
<xref linkend="sec-apache2-configuration-yast"/>, Apache is started at boot
time in the <systemitem>multi-user.target</systemitem> and
<systemitem>graphical.target</systemitem>. You can change this behavior
using &yast;'s <guimenu>&ycc_runlevel;</guimenu> or with the
<command>systemctl</command> command line tool (<command>systemctl
enable</command> or <command>systemctl disable</command>).
</para>
<para>
To start, stop, or manipulate Apache on a running system, use either the
<command>systemctl</command> or the <command>apachectl</command> commands as
described below.
</para>
<para>
For general information about <command>systemctl</command> commands, refer
to <xref linkend="sec-boot-systemd-basics-services"/>.
</para>
<variablelist>
<varlistentry>
<term><command>systemctl status apache2</command>
</term>
<listitem>
<para>
Checks if Apache is started.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>systemctl start apache2</command>
</term>
<listitem>
<para>
Starts Apache if it is not already running.
</para>
</listitem>
</varlistentry>
<!-- taroth 2014-02-11: startssl no longer supported, can be achieched
differently now, see
http://httpd.apache.org/docs/2.4/programs/apachectl.html-->
<!--
<varlistentry>
<term><option>startssl</option>
</term>
<listitem>
<para>
Starts Apache with SSL support if it is not already running. For more
information about SSL support, refer to
<xref
linkend="sec-apache2-ssl"/>.
</para>
</listitem>
</varlistentry>
-->
<varlistentry>
<term><command>systemctl stop apache2</command>
</term>
<listitem>
<para>
Stops Apache by terminating the parent process.
</para>
</listitem>
</varlistentry>
<!-- -->
<varlistentry>
<term><command>systemctl restart apache2</command>
</term>
<listitem>
<para>
Stops and then restarts Apache. Starts the Web server if it was not
running before.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>systemctl try-restart apache2</command>
</term>
<listitem>
<para>
Stops then restarts Apache only if it is already running.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>systemctl reload apache2</command>
</term>
<listitem>
<para>
Stops the Web server by advising all forked Apache processes to first
finish their requests before shutting down. As each process dies, it is
replaced by a newly started one, resulting in a complete
<quote>restart</quote> of Apache.
</para>
<tip>
<title>Restarting Apache in Production Environments</title>
<para>
This command allows activating changes in the Apache configuration
without causing connection break-offs.
</para>
</tip>
</listitem>
</varlistentry>
<!-- <varlistentry>
<term><command>apachectl -k graceful</command></term>
<listitem>
<para>
Starts a second Web server that immediately serves all incoming requests.
The previous instance of the Web server continues to handle all existing
requests for a defined period of time configured with
<systemitem>GracefulShutdownTimeout</systemitem>.
</para>
<para>
This command is useful either when upgrading to a new version or when
having changed configuration options that require a restart. Using this
option ensures a minimum server downtime.
</para>
<para>
If <systemitem>GracefulShutdownTimeout</systemitem> is set to zero, the
server will wait indefinitely until all remaining requests have been
fully served.
</para>
<para>
A graceful restart can fail if the original Apache instance is not able
to clear all necessary resources. In this case, the command will result
in a graceful stop.
</para>
</listitem>
</varlistentry> -->
<varlistentry>
<term><command>systemctl stop apache2</command></term>
<listitem>
<para>
Stops the Web server after a defined period of time configured with
<systemitem>GracefulShutdownTimeout</systemitem> to ensure that existing
requests can be finished.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>apachectl configtest</command>
</term>
<listitem>
<para>
Checks the syntax of the configuration files without affecting a running
Web server. Because this check is forced every time the server is
started, reloaded, or restarted, it is usually not necessary to run the
test explicitly (if a configuration error is found, the Web server is not
started, reloaded, or restarted).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>apachectl status</command> and
<command>apachectl fullstatus</command>
</term>
<listitem>
<para>
Dumps a short or full status screen, respectively. Requires the module
<systemitem>mod_status</systemitem> to be enabled and a text-based
browser (such as <command>links</command> or
<command>w3m</command>) installed.
<remark>
FIXME: Not sure about whether the following bit has changed since SLE
11 and rcapache2. - sknorr, 2017-06-07
</remark>
In addition to that,
<literal>status</literal> must be added to
<systemitem>APACHE_SERVER_FLAGS</systemitem> in the file
<filename>/etc/sysconfig/apache2</filename>.
</para>
</listitem>
</varlistentry>
<!-- rcapache2 could do the following two, apachectl/systemctl cannot. -
sknorr, 2017-06-07 -->
<!-- original code:
cmdline=$(echo $apache_bin -f $httpd_conf $server_flags "$@")
out=$(su - nobody -c "$cmdline" 2>&1)
case $out in
*make_sock:\ could\ not\ bind\ to\ address*) echo Syntax: OK; rc_failed=0;;
*) echo Syntax: NOT OK:; echo $out; rc_failed=1;;
esac
rc_exit -->
<!--The <option>extreme-configtest</option> options start the Web server as
user <systemitem class="username">nobody</systemitem> and actually
load the configuration, so more errors can be detected. Note that
although the configuration is loaded, it is not possible to test the
SSL setup because the SSL certificates cannot be read by
<systemitem
class="username">nobody</systemitem>.-->
<!--<varlistentry>
<term><option>probe</option>
</term>
<listitem>
<para>
Probes for the necessity of a reload (checks whether the configuration
has changed) and suggests the required arguments for the
<command>rcapache2</command> command.
</para>
</listitem>
</varlistentry>-->
<!-- original code:
for i in $httpd_conf \
$APACHE_CONF_INCLUDE_FILES \
$APACHE_CONF_INCLUDE_DIRS
do
if [ $i -nt $pidfile ]; then
echo reload
break
fi -->
</variablelist>
<tip>
<title>Additional Flags</title>
<para>
If you specify additional flags to the commands,
these are passed through to the Web server.
</para>
</tip>
</sect1>
<sect1 xml:id="sec-apache2-modules">
<title>Installing, Activating, and Configuring Modules</title>
<para>
The Apache software is built in a modular fashion: all functionality except
some core tasks are handled by modules. This has progressed so far that even
HTTP is processed by a module (<systemitem>http_core</systemitem>).
</para>
<para>
Apache modules can be compiled into the Apache binary at build time or
be dynamically loaded at runtime. Refer to
<xref linkend="sec-apache2-modules-activating"/> for details of how to load
modules dynamically.
</para>
<para>
Apache modules can be divided into four different categories:
</para>
<variablelist>
<varlistentry>
<term>Base Modules</term>
<listitem>
<para>
Base modules are compiled into Apache by default. Apache in &productname;
has only <systemitem>mod_so</systemitem> (needed to load other modules)
and <systemitem>http_core</systemitem> compiled in. All others are