Blame SPECS/httpd.service.xml

Packit 718f12
Packit 718f12
Packit 718f12
  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
Packit 718f12
Packit 718f12
]>
Packit 718f12
Packit 718f12
 Copyright 2018 Red Hat, Inc.
Packit 718f12
Packit 718f12
 Licensed to the Apache Software Foundation (ASF) under one or more
Packit 718f12
 contributor license agreements.  See the NOTICE file distributed with
Packit 718f12
 this work for additional information regarding copyright ownership.
Packit 718f12
 The ASF licenses this file to You under the Apache License, Version 2.0
Packit 718f12
 (the "License"); you may not use this file except in compliance with
Packit 718f12
 the License.  You may obtain a copy of the License at
Packit 718f12
Packit 718f12
     http://www.apache.org/licenses/LICENSE-2.0
Packit 718f12
Packit 718f12
 Unless required by applicable law or agreed to in writing, software
Packit 718f12
 distributed under the License is distributed on an "AS IS" BASIS,
Packit 718f12
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 718f12
 See the License for the specific language governing permissions and
Packit 718f12
 limitations under the License.
Packit 718f12
-->
Packit 718f12
Packit 718f12
<refentry>
Packit 718f12
  <refentryinfo>
Packit 718f12
    <title>httpd systemd units</title>
Packit 718f12
    <productname>httpd</productname>
Packit 718f12
    <author><contrib>Author</contrib><surname>Orton</surname><firstname>Joe</firstname><email>jorton@redhat.com</email></author>
Packit 718f12
  </refentryinfo>
Packit 718f12
Packit 718f12
  <refmeta>
Packit 718f12
    <refentrytitle>httpd.service</refentrytitle>
Packit 718f12
    <manvolnum>8</manvolnum>
Packit 718f12
  </refmeta>
Packit 718f12
  
Packit 718f12
  <refnamediv>
Packit 718f12
    <refname>httpd.service</refname>
Packit 718f12
    <refname>httpd@.service</refname>
Packit 718f12
    <refname>httpd.socket</refname>
Packit 718f12
    <refname>httpd-init.service</refname>
Packit 718f12
    <refpurpose>httpd unit files for systemd</refpurpose>
Packit 718f12
  </refnamediv>
Packit 718f12
Packit 718f12
  <refsynopsisdiv>
Packit 718f12
    <para>
Packit 718f12
      <filename>/usr/lib/systemd/system/httpd.service</filename>, 
Packit 718f12
      <filename>/usr/lib/systemd/system/httpd@.service</filename>,
Packit 718f12
      <filename>/usr/lib/systemd/system/httpd-init.service</filename>,
Packit 718f12
      <filename>/usr/lib/systemd/system/httpd.socket</filename>
Packit 718f12
    </para>
Packit 718f12
  </refsynopsisdiv>
Packit 718f12
  
Packit 718f12
  <refsect1>
Packit 718f12
    <title>Description</title>
Packit 718f12
Packit 718f12
    <para>This manual page describes the <command>systemd</command>
Packit 718f12
    unit files used to integrate the <command>httpd</command> daemon
Packit 718f12
    with <command>systemd</command>. Two main unit files are
Packit 718f12
    available: <command>httpd.service</command> allows the
Packit 718f12
    <command>httpd</command> daemon to be run as a system service, and
Packit 718f12
    <command>httpd.socket</command> allows httpd to be started via
Packit 718f12
    socket-based activation. Most systems will use
Packit 718f12
    <command>httpd.service</command>.</para>
Packit 718f12
Packit 718f12
    <para>The <command>apachectl</command> command has been modified
Packit 718f12
    to invoke <command>systemctl</command> for most uses, so for
Packit 718f12
    example, running <command>apachectl start</command> is equivalent
Packit 718f12
    to running <command>systemctl start httpd.service</command>.  This
Packit 718f12
    ensures that the running httpd daemon is tracked and managed by
Packit 718f12
    <command>systemd</command>.  In contrast, running
Packit 718f12
    <command>httpd</command> directly from a root shell will start the
Packit 718f12
    service outside of <command>systemd</command>; in this case,
Packit 718f12
    default security restrictions described below (including, but not
Packit 718f12
    limited to, SELinux) will not be enforced.</para>
Packit 718f12
Packit 718f12
    <refsect2>
Packit 718f12
      <title>Changing default behaviour</title>
Packit 718f12
Packit 718f12
      <para>To change the default behaviour of the httpd service, an
Packit 718f12
      <emphasis>over-ride</emphasis> file should be created, rather
Packit 718f12
      than changing
Packit 718f12
      <filename>/usr/lib/systemd/system/httpd.service</filename>
Packit 718f12
      directly, since such changes would be lost over package
Packit 718f12
      upgrades. Running <command>systemctl edit
Packit 718f12
      httpd.service</command> or <command>systemctl edit
Packit 718f12
      httpd.socket</command> as root will create a drop-in file (in
Packit 718f12
      the former case, in
Packit 718f12
      <filename>/etc/systemd/system/httpd.service.d</filename>) which
Packit 718f12
      over-rides the system defaults.</para>
Packit 718f12
Packit 718f12
      <para>For example, to set the <option>LD_LIBRARY_PATH</option>
Packit 718f12
      environment variable for the daemon, run <command>systemctl edit
Packit 718f12
      httpd.service</command> and enter:
Packit 718f12
Packit 718f12
      <programlisting>[Service]
Packit 718f12
Environment=LD_LIBRARY_PATH=/opt/vendor/lib</programlisting></para>
Packit 718f12
    </refsect2>
Packit 718f12
    
Packit 718f12
    <refsect2>
Packit 718f12
      <title>Starting the service at boot time</title>
Packit 718f12
Packit 718f12
      <para>The httpd.service and httpd.socket units are
Packit 718f12
      <emphasis>disabled</emphasis> by default. To start the httpd
Packit 718f12
      service at boot time, run: <command>systemctl enable
Packit 718f12
      httpd.service</command>. In the default configuration, the
Packit 718f12
      httpd daemon will accept connections on port 80 (and, if mod_ssl
Packit 718f12
      is installed, TLS connections on port 443) for any configured
Packit 718f12
      IPv4 or IPv6 address.</para>
Packit 718f12
Packit 718f12
      <para>If httpd is configured to depend on any specific IP
Packit 718f12
      address (for example, with a "Listen" directive) which may only
Packit 718f12
      become available during start-up, or if httpd depends on other
Packit 718f12
      services (such as a database daemon), the service
Packit 718f12
      <emphasis>must</emphasis> be configured to ensure correct
Packit 718f12
      start-up ordering.</para>
Packit 718f12
Packit 718f12
      <para>For example, to ensure httpd is only running after all
Packit 718f12
      configured network interfaces are configured, create a drop-in
Packit 718f12
      file (as described above) with the following section:
Packit 718f12
Packit 718f12
      <programlisting>[Unit]
Packit 718f12
After=network-online.target
Packit 718f12
Wants=network-online.target</programlisting>
Packit 718f12
Packit 718f12
      See 
Packit 718f12
      url="https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/"/>
Packit 718f12
      for more information on start-up ordering with systemd.</para>
Packit 718f12
Packit 718f12
    </refsect2>
Packit 718f12
Packit 718f12
    <refsect2>
Packit 718f12
      <title>SSL/TLS certificate generation</title>
Packit 718f12
Packit 718f12
      <para>The <command>httpd-init.service</command> unit is provided
Packit 718f12
      with the mod_ssl package. This oneshot unit automatically
Packit 718f12
      creates a TLS server certificate and key (using a generated
Packit 718f12
      self-signed CA certificate and key) for testing purposes before
Packit 718f12
      httpd is started. To inhibit certificate generation, use
Packit 718f12
      <command>systemctl mask httpd-init.service</command> after
Packit 718f12
      installing mod_ssl, and adjust the mod_ssl configuration to use
Packit 718f12
      an appropriate certificate and key.</para>
Packit 718f12
Packit 718f12
    </refsect2>
Packit 718f12
Packit 718f12
    <refsect2>
Packit 718f12
      <title>Reloading and stopping the service</title>
Packit 718f12
Packit 718f12
      <para>When running <command>systemctl reload
Packit 718f12
      httpd.service</command>, a <emphasis>graceful</emphasis>
Packit 718f12
      restart is used, which sends a signal to the httpd parent
Packit 718f12
      process to reload the configuration and re-open log files. Any
Packit 718f12
      children with open connections at the time of reload will
Packit 718f12
      terminate only once they have completed serving requests. This
Packit 718f12
      prevents users of the server seeing errors (or potentially
Packit 718f12
      losing data) due to the reload, but means some there is some
Packit 718f12
      delay before any configuration changes take effect for all
Packit 718f12
      users.</para>
Packit 718f12
Packit 718f12
      <para>Similarly, a <emphasis>graceful stop</emphasis> is used
Packit 718f12
      when <command>systemctl stop httpd.service</command> is run,
Packit 718f12
      which terminates the server only once active connections have
Packit 718f12
      been processed.</para>
Packit 718f12
Packit 718f12
      <para>To "ungracefully" stop the server without waiting for
Packit 718f12
      requests to complete, use <command>systemctl kill
Packit 718f12
      --kill-who=main httpd</command>; similarly to "ungracefully"
Packit 718f12
      reload the configuration, use <command>systemctl kill
Packit 718f12
      --kill-who=main --signal=HUP httpd</command>.</para>
Packit 718f12
    </refsect2>
Packit 718f12
Packit 718f12
    <refsect2>
Packit 718f12
      <title>Automated service restarts</title>
Packit 718f12
Packit 718f12
      <para>System packages (including the httpd package itself) may
Packit 718f12
      restart the httpd service automatically after packages are
Packit 718f12
      upgraded, installed, or removed. This is done using the
Packit 718f12
      <command>systemctl reload httpd.service</command>, which
Packit 718f12
      produces a <emphasis>graceful</emphasis> restart by default as
Packit 718f12
      described above.</para>
Packit 718f12
Packit 718f12
      <para>To suppress automatic reloads entirely, create the file
Packit 718f12
      <filename>/etc/sysconfig/httpd-disable-posttrans</filename>.</para>
Packit 718f12
    </refsect2>
Packit 718f12
Packit 718f12
    <refsect2>
Packit 718f12
      <title>Changing the default MPM (Multi-Processing Module)</title>
Packit 718f12
Packit 718f12
      <para>httpd offers a choice of multi-processing modules (MPMs),
Packit 718f12
      which can be configured in
Packit 718f12
      <filename>/etc/httpd/conf.modules.d/00-mpm.conf</filename>.
Packit 718f12
      See
Packit 718f12
      <citerefentry><refentrytitle>httpd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
Packit 718f12
      for more information on changing the MPM.</para>
Packit 718f12
    </refsect2>
Packit 718f12
Packit 718f12
    <refsect2>
Packit 718f12
      <title>systemd integration and mod_systemd</title>
Packit 718f12
Packit 718f12
      <para>The httpd service uses the <option>notify</option> systemd
Packit 718f12
      service type. The <literal>mod_systemd</literal> module must be
Packit 718f12
      loaded (as in the default configuration) for this to work
Packit 718f12
      correctly - the service will fail if this module is not
Packit 718f12
      loaded. <literal>mod_systemd</literal> also makes worker and
Packit 718f12
      request statistics available when running <command>systemctl status
Packit 718f12
      httpd</command>. See
Packit 718f12
      <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
Packit 718f12
      for more information on systemd service types.</para>
Packit 718f12
    </refsect2>
Packit 718f12
    
Packit 718f12
    <refsect2>
Packit 718f12
      <title>Security and SELinux</title>
Packit 718f12
Packit 718f12
      <para>The default SELinux policy restricts the httpd service in
Packit 718f12
      various ways. For example, the default policy limits the ports
Packit 718f12
      to which httpd can bind (using the <literal>Listen</literal>
Packit 718f12
      directive), which parts of the filesystem can be accessed, and
Packit 718f12
      whether outgoing TCP connections are possible. Many of these
Packit 718f12
      restrictions can be relaxed or adjusted by using
Packit 718f12
      <command>semanage</command> to change booleans or other
Packit 718f12
      types. See
Packit 718f12
      <citerefentry><refentrytitle>httpd_selinux</refentrytitle><manvolnum>8</manvolnum></citerefentry>
Packit 718f12
      for more information.</para>
Packit 718f12
Packit 718f12
      <para>The httpd service enables <emphasis>PrivateTmp</emphasis>
Packit 718f12
      by default. The <filename>/tmp</filename> and
Packit 718f12
      <filename>/var/tmp</filename> directories available within the
Packit 718f12
      httpd process (and CGI scripts, etc) are not shared by other
Packit 718f12
      processes. See
Packit 718f12
      <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
Packit 718f12
      for more information.</para>
Packit 718f12
Packit 718f12
    </refsect2>
Packit 718f12
Packit 718f12
    <refsect2>
Packit 718f12
      <title>Socket activation</title>
Packit 718f12
Packit 718f12
      <para>Socket activation (see
Packit 718f12
      <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>
Packit 718f12
      for more information) can be used with <command>httpd</command>
Packit 718f12
      by enabling the <command>httpd.socket</command> unit.  The
Packit 718f12
      <command>httpd</command> listener configuration must exactly
Packit 718f12
      match the <literal>ListenStream</literal> options configured for
Packit 718f12
      the <command>httpd.socket</command> unit.  The default
Packit 718f12
      <command>httpd.socket</command> has a
Packit 718f12
      <literal>ListenStream=80</literal> and, if mod_ssl is installed,
Packit 718f12
      <literal>ListenStream=443</literal> by a drop-in file. If
Packit 718f12
      additional <literal>Listen</literal> directives are added to the
Packit 718f12
      httpd configuration, corresponding
Packit 718f12
      <literal>ListenStream</literal> options should be added via
Packit 718f12
      drop-in files, for example via <command>systemctl edit
Packit 718f12
      httpd.socket</command>.</para>
Packit 718f12
Packit 718f12
      <para>If using socket activation with httpd, only one listener
Packit 718f12
      on any given TCP port is supported; a configuration with both
Packit 718f12
      "<literal>Listen 127.0.0.1:80</literal>" and "<literal>Listen
Packit 718f12
      192.168.1.2:80</literal>" will not work.</para>
Packit 718f12
    </refsect2>
Packit 718f12
Packit 718f12
    <refsect2>
Packit 718f12
      <title>Instantiated services</title>
Packit 718f12
Packit 718f12
      <para>The <command>httpd@.service</command> unit is an
Packit 718f12
      instantiated template service. An instance of this unit will be
Packit 718f12
      started using the configuration file
Packit 718f12
      <filename>/etc/httpd/conf/INSTANCE.conf</filename>, where
Packit 718f12
      <emphasis>INSTANCE</emphasis> is replaced with the instance
Packit 718f12
      name.  For example, <command>systemctl start
Packit 718f12
      httpd@foobar.service</command> will start httpd using the
Packit 718f12
      configuration file
Packit 718f12
      <filename>/etc/httpd/conf/foobar.conf</filename>.  The
Packit 718f12
      <option>HTTPD_INSTANCE</option> environment variable is set to
Packit 718f12
      the instance name by the unit and is available for use within
Packit 718f12
      the configuration file.</para>
Packit 718f12
Packit 718f12
      <para>To allow multiple instances of httpd to run
Packit 718f12
      simultaneously, a number of configuration directives must be
Packit 718f12
      changed, such as <command>PidFile</command> and
Packit 718f12
      <command>DefaultRuntimeDir</command> to pick non-conflicting
Packit 718f12
      paths, and <command>Listen</command> to choose different ports.
Packit 718f12
      The example configuration file
Packit 718f12
      <filename>/usr/share/doc/httpd/instance.conf</filename>
Packit 718f12
      demonstrates how to make such changes using
Packit 718f12
      <option>HTTPD_INSTANCE</option> variable.</para>
Packit 718f12
Packit 718f12
      <para>It can be useful to configure instances of
Packit 718f12
      <command>httpd@.service</command> to reload when
Packit 718f12
      <command>httpd.service</command> is reloaded; for example,
Packit 718f12
      <command>logrotate</command> will reload only
Packit 718f12
      <command>httpd.service</command> when logs are rotated. If this
Packit 718f12
      behaviour is required, create a drop-in file for the instance as
Packit 718f12
      follows:
Packit 718f12
Packit 718f12
      <programlisting>[Unit]
Packit 718f12
ReloadPropagatedFrom=httpd.service</programlisting>
Packit 718f12
Packit 718f12
      As with normal units, drop-in files for instances can be created
Packit 718f12
      using <command>systemctl edit</command>, e.g. <command>systemctl edit
Packit 718f12
      httpd@foobar.service</command>.</para>
Packit 718f12
    </refsect2>
Packit 718f12
Packit 718f12
  </refsect1>
Packit 718f12
Packit 718f12
  <refsect1>
Packit 718f12
    <title>Files</title>
Packit 718f12
Packit 718f12
    <para><filename>/usr/lib/systemd/system/httpd.service</filename>,
Packit 718f12
    <filename>/usr/lib/systemd/system/httpd.socket</filename>,
Packit 718f12
    <filename>/usr/lib/systemd/system/httpd@.service</filename>,
Packit 718f12
    <filename>/etc/systemd/systemd/httpd.service.d</filename></para>
Packit 718f12
  </refsect1>
Packit 718f12
  
Packit 718f12
  <refsect1>
Packit 718f12
    <title>See also</title>
Packit 718f12
Packit 718f12
    <para>
Packit 718f12
    <citerefentry><refentrytitle>httpd</refentrytitle><manvolnum>8</manvolnum></citerefentry>, 
Packit 718f12
    <citerefentry><refentrytitle>httpd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
Packit 718f12
    <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, 
Packit 718f12
    <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, 
Packit 718f12
    <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
Packit 718f12
    <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
Packit 718f12
    <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
Packit 718f12
    <citerefentry><refentrytitle>httpd_selinux</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
Packit 718f12
    <citerefentry><refentrytitle>semanage</refentrytitle><manvolnum>8</manvolnum></citerefentry>
Packit 718f12
    </para>
Packit 718f12
  </refsect1>
Packit 718f12
Packit 718f12
</refentry>
Packit 718f12
Packit 718f12
Packit 718f12
-->