#302 Technical review on getting-started-with-apache-http-server
Closed 3 years ago by copperi. Opened 3 years ago by copperi.
fedora-docs/ copperi/quick-docs technical_review  into  master

@@ -7,20 +7,20 @@ 

  

  As a best practice, do not modify `/etc/httpd/conf/httpd.conf` or any of the `/etc/httpd/conf.d` files shipped by Fedora packages directly. If you make any local changes to these files, then any changes to them in newer package versions will not be directly applied. Instead, a `.rpmnew` file will be created, and you will have to merge the changes manually.

  

- It is recommended to create a new file in `/etc/httpd/conf.d` which will take precedence over the file you wish to modify, and edit the required settings. For instance, to change a setting specified in `/etc/httpd/conf.d/foo.conf` you could create the file `/etc/httpd/conf.d/z-foo-local.conf`, and place your setting in that file.

+ It is recommended to create a new file in `/etc/httpd/conf.d/` which will take precedence over the file you wish to modify, and edit the required settings. For instance, to change a setting specified in `/etc/httpd/conf.d/foo.conf` you could create the file `/etc/httpd/conf.d/z-foo-local.conf`, and place your setting in that file.

  

  [NOTE]

  ====

  After making any changes to your server configuration, execute the following command:

  

  ----

- # apachectl reload

+ # sudo systemctl reload httpd.service

  ----

  

  Certain changes may require Apache to be fully restarted. To fully restart Apache, execute the following command:

  

  ----

- # systemctl restart httpd.service

+ # sudo systemctl restart httpd.service

  ----

  ====

  
@@ -99,13 +99,13 @@ 

  * For plain HTTP connections:

  +

  ----

- # firewall-cmd --permanent --add-service=http

+ # sudo firewall-cmd --permanent --add-service=http

  ----

  

  * For TLS/SSL connections:

  +

  ----

- # firewall-cmd --permanent --add-service=https

+ # sudo firewall-cmd --permanent --add-service=https

  ----

  

  To allow Apache through the firewall instantly:
@@ -113,13 +113,13 @@ 

  * For plain HTTP connections:

  +

  ----

- # firewall-cmd --add-service=http

+ # sudo firewall-cmd --add-service=http

  ----

  

  * For TLS/SSL connections:

  +

  ----

- # firewall-cmd --add-service=https

+ # sudo firewall-cmd --add-service=https

  ----

  

  NOTE: If your server is running in a network with a NAT router, you will also need to configure your router to forward the HTTP and HTTPS ports to your server, if you wish to allow access from outside your local network.

@@ -6,13 +6,13 @@ 

  . Install *HTTPD* packages.

  +

  ----

- # dnf install httpd -y

+ # sudo dnf install httpd -y

  ----

  

  . Start the *HTTPD* service.

  +

  ----

- # systemctl start httpd.service

+ # sudo systemctl start httpd.service

  ----

  

  [NOTE]
@@ -20,7 +20,7 @@ 

  To enable auto start of *HTTPD* service at boot, execute the following command:

  

  ----

- # systemctl enable httpd.service

+ # sudo systemctl enable httpd.service

  ----

  ====

  

@@ -14,7 +14,7 @@ 

  Most web applications are simply packaged according to their name. For instance, you can install Wordpress by executing the following command:

  

  ----

- # dnf install wordpress

+ # sudo dnf install wordpress

  ----

  

  Packaged web applications will usually provide Fedora-specific instructions in a documentation file. For instance, Wordpress provides the files `/usr/share/doc/wordpress/README.fedora` and `/usr/share/doc/wordpress/README.fedora-multiuser`.

@@ -18,7 +18,7 @@ 

  The https://apps.fedoraproject.org/packages/mod_ssl[mod_ssl] package will be automatically enabled post installation. Install the https://apps.fedoraproject.org/packages/mod_ssl[mod_ssl] package using the following command:

  

  ----

- # dnf install mod_ssl -y

+ # sudo dnf install mod_ssl -y

  ----

  

  
@@ -37,8 +37,8 @@ 

  . Move the certificate and the key file to the correct folder

  +

  ----

- # mv key_file.key /etc/pki/tls/private/myhost.com.key

- # mv certificate.crt /etc/pki/tls/certs/myhost.com.crt

+ # sudo mv key_file.key /etc/pki/tls/private/myhost.com.key

+ # sudo mv certificate.crt /etc/pki/tls/certs/myhost.com.crt

  ----

  +

  . Ensure that the following parameters are correct:
@@ -53,15 +53,15 @@ 

  .. Ownership

  +

  ----

- # chown root.root /etc/pki/tls/private/myhost.com.key

- # chown root.root /etc/pki/tls/certs/myhost.com.crt

+ # sudo chown root.root /etc/pki/tls/private/myhost.com.key

+ # sudo chown root.root /etc/pki/tls/certs/myhost.com.crt

  ----

  +

  .. Permissions

  +

  ----

- # chmod 0600 /etc/pki/tls/private/myhost.com.key

- # chmod 0600 /etc/pki/tls/certs/myhost.com.crt

+ # sudo chmod 0600 /etc/pki/tls/private/myhost.com.key

+ # sudo chmod 0600 /etc/pki/tls/certs/myhost.com.crt

  ----

  

  After installing the existing certificate, set up the certificate using <<mod_ssl configuration>>.

@@ -3,8 +3,6 @@ 

  [id='getting-started-with-apache-http-server']

  = Getting started with Apache HTTP Server

  

- include::{partialsdir}/unreviewed-message.adoc[]

- 

  The Apache HTTP Server is one of the most commonly-used web servers. This section acts as a quick-start guide to deploying and configuring Apache on Fedora.

  

  include::{partialsdir}/proc_installing-httpd.adoc[leveloffset=+1]

@@ -0,0 +1,892 @@ 

+ <!DOCTYPE html>

+ <html lang="en">

+   <head>

+     <meta charset="utf-8">

+     <meta name="viewport" content="width=device-width, initial-scale=1.0">

+     <title>Getting started with Apache HTTP Server :: Local Preview</title>

+     <meta name="generator" content="Antora 2.3.4">

+     <link rel="stylesheet" href="../../_/css/site.css">

+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">  </head>

+   <body class="article">

+ <header class="header" role="banner">

+   <nav class="navbar" style="">

+     <div class="navbar-brand">

+       <a class="navbar-item" href="../..">

+         <img src="../../_/img/docs_logo.png" style="height:40px">

+       </a>

+       <!-- We don't have anything in the menu, but the burger still appears

+            on mobile devices. So let's remove it. -->

+       <!--<button class="navbar-burger" data-target="topbar-nav">

+         <span></span>

+         <span></span>

+         <span></span>

+       </button>-->

+     </div>

+     <div id="topbar-nav" class="navbar-menu">

+       <div class="navbar-end">

+         

+       </div>

+     </div>

+   </nav>

+ </header>

+ <div class="main-wrapper">

+ <div class="navigation-container" data-component="quick-docs" data-version="master">

+   <aside class="navigation" role="navigation">

+     <div class="panels">

+ <div class="navigation-menu is-active" data-panel="menu">

+   <nav class="nav-menu">

+     <h3 class="title"><a href="../">Quick Docs</a></h3>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="0">

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="1">

+     <a class="nav-link" href="../contribute-to-quick-docs/">Contribute to Quick Docs</a>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <a class="nav-link" href="../howto-file-a-bug/">How to file a bug</a>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <a class="nav-link" href="../getting-started-guide/">Getting started with Fedora</a>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <button class="nav-toggle"></button>

+     <span class="nav-text">Installation</span>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../creating-and-using-a-live-installation-image/">Creating and using a live installation image</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../raspberry-pi/">Fedora on Raspberry Pi</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <button class="nav-toggle"></button>

+     <a class="nav-link" href="../anaconda/anaconda/">Anaconda: the Fedora installer</a>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="3">

+     <a class="nav-link" href="../anaconda/anaconda_logging/">Anaconda Logging</a>

+   </li>

+ </ul>

+   </li>

+ </ul>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <button class="nav-toggle"></button>

+     <span class="nav-text">Usage and customisation</span>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../dnf/">Using the DNF software package manager</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../repositories/">Fedora Repositories</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../finding-and-installing-linux-applications/">Finding and installing Linux applications</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../adding-or-removing-software-repositories-in-fedora/">Adding or removing software repositories in Fedora</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../setup_rpmfusion/">Enabling the RPM Fusion repositories</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../installing-chromium-or-google-chrome-browsers/">Installing Chromium or Google Chrome browsers</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../switching-desktop-environments/">Switching desktop environments</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../configuring-x-window-system-using-the-xorg-conf-file/">Configuring X Window System using the xorg.conf file</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../configuring-xorg-as-default-gnome-session/">Configuring X.org as the default GNOME session</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../gnome-shell-extensions/">Using GNOME Shell extensions</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../wine/">Running Windows applications with Wine</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../using-adobe-flash/">Using Adobe Flash</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../fonts/">Adding new fonts</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../create-gpg-keys/">Creating GPG Keys</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../bootloading-with-grub2/">Bootloading with GRUB2</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../securing-the-system-by-keeping-it-up-to-date/">Securing the system by keeping it up-to-date</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../installing-java/">Installing Java</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../proc_setting-key-shortcut/">Setting a key shortcut to run an application in GNOME</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../disabling-automatic-screenlock/">Disabling the GNOME automatic screen locking</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../viewing-logs/">Viewing logs in Fedora</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../encrypting-drives-using-LUKS/">Encrypting drives using LUKS</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../assembly_installing-plugins-for-playing-movies-and-music/">Installing plugins for playing movies and music</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../installing-and-running-vlc/">Installing and running the VLC player</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../configuring-ip-networking-with-nmcli/">Configuring networking with NetworkManager CLI (nmcli)</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../using-shared-system-certificates/">Using shared system certificates</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../installing-spotify/">Installing Spotify on Fedora</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../installing-skype/">Installing Skype on Fedora</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../adding_user_to_sudoers_file/">Adding a user to sudoers</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../performing-administration-tasks-using-sudo/">Performing administration tasks using sudo</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../understanding-and-administering-systemd/">Understanding and administering systemd</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../displaying_user_prompt_on_gnome_login_screen/">Displaying a user prompt on the GNOME login screen</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../firewalld/">Controlling network traffic with firewalld</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../managing-keyboard-shortcuts-for-running-app-in-gnome/">Managing keyboard shortcuts for running an application in GNOME</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../creating-a-disk-partition-in-linux/">Creating disk partitions</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../reset-root-password/">Resetting a root password</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../using-aide/">Checking file integrity with AIDE</a>

+   </li>

+   <li class="nav-item is-current-page" data-depth="2">

+     <a class="nav-link" href="./">Getting started with Apache HTTP Server</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../how-to-edit-iptables-rules/">How to edit iptables rules</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <button class="nav-toggle"></button>

+     <span class="nav-text">NVIDIA</span>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="3">

+     <a class="nav-link" href="../bumblebee/">NVIDIA Optimus Bumblebee</a>

+   </li>

+   <li class="nav-item" data-depth="3">

+     <a class="nav-link" href="../how-to-set-nvidia-as-primary-gpu-on-optimus-based-laptops/">How to Set NVIDIA as Primary GPU on Optimus-based Laptops</a>

+   </li>

+ </ul>

+   </li>

+ </ul>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <button class="nav-toggle"></button>

+     <a class="nav-link" href="../getting-started-with-selinux/">SELinux</a>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../changing-selinux-states-and-modes/">Changing SELinux states and modes</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../troubleshooting_selinux/">Troubleshooting SELinux</a>

+   </li>

+ </ul>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <button class="nav-toggle"></button>

+     <a class="nav-link" href="../upgrading/">Upgrading to a new release</a>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../dnf-system-upgrade/">Upgrading Fedora using the DNF system upgrade</a>

+   </li>

+ </ul>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <button class="nav-toggle"></button>

+     <a class="nav-link" href="../kernel/overview/">Kernel</a>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../kernel/troubleshooting/">Troubleshooting</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../kernel/build-custom-kernel/">Building a Custom Kernel</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../kernel/howto-kernel-testday/">Guide for Kernel Test Days</a>

+   </li>

+ </ul>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <button class="nav-toggle"></button>

+     <span class="nav-text">Virtualization</span>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../getting-started-with-virtualization/">Getting started with virtualization (libvirt)</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../installing-virtual-systems-with-gnome-boxes/">Installing virtual operating systems with GNOME Boxes</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../qemu/">Using virtualization emulation in QEMU</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../using-nested-virtualization-in-kvm/">Using nested virtualization in KVM</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../creating-windows-virtual-machines-using-virtio-drivers/">Creating Windows virtual machines using virtIO drivers</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../how-to-use-vmware/">How to use Vmware Product&#8217;s</a>

+   </li>

+ </ul>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <a class="nav-link" href="../autoupdates/">AutoUpdates</a>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <a class="nav-link" href="../debug-dracut-problems/">How to debug Dracut problems</a>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <a class="nav-link" href="../openh264/">OpenH264</a>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <a class="nav-link" href="../package-management/">Package management system</a>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <a class="nav-link" href="../packagekit-not-found/">PackageKit Items Not Found</a>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <a class="nav-link" href="../postgresql/">PostgreSQL</a>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <a class="nav-link" href="../upgrading-fedora-online/">Upgrading Fedora using package manager</a>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <button class="nav-toggle"></button>

+     <a class="nav-link" href="../creating-rpm-packages/">Creating RPM packages</a>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../create-hello-world-rpm/">Creating a GNU Hello World RPM Package</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../publish-rpm-on-copr/">Publishing your software on Copr</a>

+   </li>

+ </ul>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <button class="nav-toggle"></button>

+     <span class="nav-text">Databases</span>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../installing-mysql-mariadb/">Installing, Configuring and Troubleshooting MySql/MariaDB</a>

+   </li>

+ </ul>

+   </li>

+   <li class="nav-item" data-depth="1">

+     <button class="nav-toggle"></button>

+     <span class="nav-text">FAQ</span>

+ <ul class="nav-list">

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../fedora-and-red-hat-enterprise-linux/">Difference between Fedora and Red Hat Enterprise Linux</a>

+   </li>

+   <li class="nav-item" data-depth="2">

+     <a class="nav-link" href="../dnf-vs-apt/">APT commands on Fedora</a>

+   </li>

+ </ul>

+   </li>

+ </ul>

+   </li>

+ </ul>

+   </nav>

+ </div>

+ <div class="navigation-explore" data-panel="explore">

+   <div class="context">

+     <span class="title">Quick Docs</span>

+     <span class="version">master</span>

+   </div>

+   <ul class="components">

+     <li class="component is-current">

+       <span class="title">Quick Docs</span>

+       <ul class="versions">

+         <li class="version is-current is-latest">

+           <a href="../">master</a>

+         </li>

+       </ul>

+     </li>

+   </ul>

+ </div>

+     </div>

+   </aside>

+ </div>

+   <main class="main" role="main">

+ <div class="toolbar" role="navigation">

+   <button class="navigation-toggle"></button>

+ <nav class="crumbs" role="navigation" aria-label="breadcrumbs">

+   

+   <ul>

+       <li class="crumb HO"><a href="../">Home</a></li>

+     <li class="crumb HO"><a href="../">Quick Docs</a></li>

+     <li class="crumb HA">Usage and customisation</li>

+     <li class="crumb HA"><a href="./">Getting started with Apache HTTP Server</a></li>

+   </ul>

+   

+ </nav>

+ </div>

+ <article class="doc">

+ <h1>Getting started with Apache HTTP Server</h1>

+ <div id="preamble">

+ <div class="sectionbody">

+ <div class="admonitionblock caution">

+ <table>

+ <tr>

+ <td class="icon">

+ <i class="fa icon-caution" title="Caution"></i>

+ </td>

+ <td class="content">

+ <div class="paragraph">

+ <p>This page has been converted from the Fedora Project Wiki and cleaned up for publishing here on the Fedora Docs Portal, but it has not yet been reviewed for technical accuracy.

+ This means any information on this page may be outdated or inaccurate.

+ Reviews for technical accuracy are greatly appreciated. If you want to help, see the <a href="https://pagure.io/fedora-docs/quick-docs/blob/master/f/README.md">README</a> file in the source repository for instructions.</p>

+ </div>

+ </td>

+ </tr>

+ </table>

+ </div>

+ <div class="paragraph">

+ <p>The Apache HTTP Server is one of the most commonly-used web servers. This section acts as a quick-start guide to deploying and configuring Apache on Fedora.</p>

+ </div>

+ </div>

+ </div>

+ <div class="sect1">

+ <h2 id="installing-httpd"><a class="anchor" href="#installing-httpd"></a>Installing HTTPD</h2>

+ <div class="sectionbody">

+ <div class="paragraph">

+ <p>This procedure describes the steps to install Apache <strong>HTTPD</strong> on Fedora.</p>

+ </div>

+ <div class="olist arabic">

+ <ol class="arabic">

+ <li>

+ <p>Install <strong>HTTPD</strong> packages.</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre># sudo dnf install httpd -y</pre>

+ </div>

+ </div>

+ </li>

+ <li>

+ <p>Start the <strong>HTTPD</strong> service.</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre># sudo systemctl start httpd.service</pre>

+ </div>

+ </div>

+ </li>

+ </ol>

+ </div>

+ <div class="admonitionblock note">

+ <table>

+ <tr>

+ <td class="icon">

+ <i class="fa icon-note" title="Note"></i>

+ </td>

+ <td class="content">

+ <div class="paragraph">

+ <p>To enable auto start of <strong>HTTPD</strong> service at boot, execute the following command:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre># sudo systemctl enable httpd.service</pre>

+ </div>

+ </div>

+ </td>

+ </tr>

+ </table>

+ </div>

+ <div class="paragraph">

+ <p>Navigate to <a href="http://localhost">http://localhost</a> to access the Apache test page. You may not be able to access the server from any other host. To access the server from other hosts, see <a href="#opening-firewall-ports">Opening firewall ports</a>.</p>

+ </div>

+ </div>

+ </div>

+ <div class="sect1">

+ <h2 id="securing-apache-httpd"><a class="anchor" href="#securing-apache-httpd"></a>Securing Apache HTTPD</h2>

+ <div class="sectionbody">

+ <div class="paragraph">

+ <p>To enable TLS/SSL support, download and install one of the following packages:</p>

+ </div>

+ <div class="ulist">

+ <ul>

+ <li>

+ <p><a href="https://apps.fedoraproject.org/packages/mod_ssl">mod_ssl</a>, based on <a href="https://www.openssl.org">OpenSSL</a></p>

+ </li>

+ <li>

+ <p><a href="https://apps.fedoraproject.org/packages/mod_gnutls">mod_gnutls</a>, based on <a href="https://www.gnutls.org/">GnuTLS</a></p>

+ </li>

+ <li>

+ <p><a href="https://apps.fedoraproject.org/packages/mod_nss">mod_nss</a>, based on <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS">NSS</a></p>

+ </li>

+ </ul>

+ </div>

+ <div class="sect2">

+ <h3 id="using-mod-ssl"><a class="anchor" href="#using-mod-ssl"></a>Using mod_ssl</h3>

+ <div class="sect3">

+ <h4 id="installing-mod-ssl"><a class="anchor" href="#installing-mod-ssl"></a>Installing mod_ssl</h4>

+ <div class="paragraph">

+ <p>The <a href="https://apps.fedoraproject.org/packages/mod_ssl">mod_ssl</a> package will be automatically enabled post installation. Install the <a href="https://apps.fedoraproject.org/packages/mod_ssl">mod_ssl</a> package using the following command:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre># dnf install mod_ssl -y</pre>

+ </div>

+ </div>

+ </div>

+ <div class="sect3">

+ <h4 id="generating-new-certificate"><a class="anchor" href="#generating-new-certificate"></a>Generating a new certificate</h4>

+ <div class="paragraph">

+ <p>To generate a new certificate, refer to <a href="https://fedoraproject.org/wiki/Https#openssl">Create a certificate using OpenSSL</a>.</p>

+ </div>

+ </div>

+ <div class="sect3">

+ <h4 id="installing-existing-certificate"><a class="anchor" href="#installing-existing-certificate"></a>Installing an existing certificate</h4>

+ <div class="paragraph">

+ <p>If you already have a certificate generated on another computer, do the following:</p>

+ </div>

+ <div class="olist arabic">

+ <ol class="arabic">

+ <li>

+ <p>Move the certificate and the key file to the correct folder</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre># mv key_file.key /etc/pki/tls/private/myhost.com.key

+ # mv certificate.crt /etc/pki/tls/certs/myhost.com.crt</pre>

+ </div>

+ </div>

+ </li>

+ <li>

+ <p>Ensure that the following parameters are correct:</p>

+ <div class="olist loweralpha">

+ <ol class="loweralpha" type="a">

+ <li>

+ <p>SELinux contexts</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre># restorecon /etc/pki/tls/private/myhost.com.key

+ # restorecon /etc/pki/tls/certs/myhost.com.crt</pre>

+ </div>

+ </div>

+ </li>

+ <li>

+ <p>Ownership</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre># chown root.root /etc/pki/tls/private/myhost.com.key

+ # chown root.root /etc/pki/tls/certs/myhost.com.crt</pre>

+ </div>

+ </div>

+ </li>

+ <li>

+ <p>Permissions</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre># chmod 0600 /etc/pki/tls/private/myhost.com.key

+ # chmod 0600 /etc/pki/tls/certs/myhost.com.crt</pre>

+ </div>

+ </div>

+ </li>

+ </ol>

+ </div>

+ </li>

+ </ol>

+ </div>

+ <div class="paragraph">

+ <p>After installing the existing certificate, set up the certificate using <a href="#mod-ssl-configuration">mod_ssl configuration</a>.</p>

+ </div>

+ </div>

+ <div class="sect3">

+ <h4 id="mod-ssl-configuration"><a class="anchor" href="#mod-ssl-configuration"></a>mod_ssl configuration</h4>

+ <div class="paragraph">

+ <p>The default TLS/SSL configuration is contained in the file <code>/etc/httpd/conf.d/ssl.conf</code>. In the <code>ssl.conf</code> file, following are the directives that specify where the TLS/SSL certificate and key are located:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre>SSLCertificateFile /etc/pki/tls/certs/localhost.crt

+ SSLCertificateKeyFile /etc/pki/tls/private/localhost.key</pre>

+ </div>

+ </div>

+ <div class="paragraph">

+ <p>These directives are enclosed in a block defining a <a href="https://httpd.apache.org/docs/current/vhosts/">virtual host</a>:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre>&lt;VirtualHost _default_:443&gt;

+ ...

+ SSLCertificateFile /etc/pki/tls/certs/localhost.crt

+ ...

+ SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

+ ...

+ &lt;/VirtualHost&gt;</pre>

+ </div>

+ </div>

+ <div class="paragraph">

+ <p>To define a different location for these files, do the following:</p>

+ </div>

+ <div class="olist arabic">

+ <ol class="arabic">

+ <li>

+ <p>Create a copy of the <code>/etc/httpd/conf.d/ssl.conf</code> file and renew the file to <code>z-ssl-local.conf</code>.</p>

+ </li>

+ <li>

+ <p>Edit the following lines in the <code>z-ssl-local.conf</code> file:</p>

+ </li>

+ </ol>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre>&lt;VirtualHost _default_:443&gt;

+ SSLCertificateFile /etc/pki/tls/certs/www.myhost.org.crt

+ SSLCertificateKeyFile /etc/pki/tls/private/www.myhost.org.key

+ &lt;/VirtualHost&gt;</pre>

+ </div>

+ </div>

+ <div class="paragraph">

+ <p>This file will override the two settings for the <code>_default_:443</code> virtual host; all other settings from <code>ssl.conf</code> will be retained.</p>

+ </div>

+ </div>

+ <div class="sect3">

+ <h4 id="settings-individual-virtual-hosts"><a class="anchor" href="#settings-individual-virtual-hosts"></a>Settings for individual virtual hosts</h4>

+ <div class="paragraph">

+ <p>To use SSL/TLS for a specific virtual host with a different certificate as default, do the following:</p>

+ </div>

+ <div class="olist arabic">

+ <ol class="arabic">

+ <li>

+ <p>Open that virtual host&#8217;s configuration file <code>/etc/httpd/conf.d/hostname.conf</code>.</p>

+ </li>

+ <li>

+ <p>Insert these lines between <code>&lt;VirtualHost hostname:port&gt;</code> and <code>&lt;/VirtualHost&gt;</code>:</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre>SSLEngine on

+ SSLCertificateFile /etc/pki/tls/certs/hostname.crt

+ SSLCertificateKeyFile /etc/pki/tls/private/hostname.key</pre>

+ </div>

+ </div>

+ </li>

+ </ol>

+ </div>

+ </div>

+ </div>

+ </div>

+ </div>

+ <div class="sect1">

+ <h2 id="installing-webapps"><a class="anchor" href="#installing-webapps"></a>Installing webapps</h2>

+ <div class="sectionbody">

+ <div class="paragraph">

+ <p>You probably want to run something on your web server. Many of the most popular web applications are packaged for Fedora. Using the packaged versions of web applications is recommended. These packages will be configured following the distribution&#8217;s best practices which help to ensure the security of the installation.</p>

+ </div>

+ <div class="paragraph">

+ <p>For instance, by installing static files to locations the web server does not have the ability to write to, and doing access control with configuration files rather than <code>.htaccess</code> files, which are slightly more vulnerable to attack.</p>

+ </div>

+ <div class="paragraph">

+ <p>Packaged web applications will also be configured to work with SELinux, which provides significant security benefits.</p>

+ </div>

+ <div class="paragraph">

+ <p>You will also receive updates through the usual Fedora update process, making it easier to keep your installation up to date.</p>

+ </div>

+ <div class="paragraph">

+ <p>They will also often have the default configuration tweaked according to Fedora&#8217;s conventions, meaning you have to do less work to get the application up and running.</p>

+ </div>

+ <div class="paragraph">

+ <p>Most web applications are simply packaged according to their name. For instance, you can install Wordpress by executing the following command:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre># dnf install wordpress</pre>

+ </div>

+ </div>

+ <div class="paragraph">

+ <p>Packaged web applications will usually provide Fedora-specific instructions in a documentation file. For instance, Wordpress provides the files <code>/usr/share/doc/wordpress/README.fedora</code> and <code>/usr/share/doc/wordpress/README.fedora-multiuser</code>.</p>

+ </div>

+ <div class="paragraph">

+ <p>Packaged web applications usually restrict access by default so you can access them only from the server host itself, to ensure you can run all initial configuration safely and things like administration interfaces are not left accessible to the public. For information on how to broaden access, see <a href="#enabling-access-to-web-applications">Enabling access to web applications</a>.</p>

+ </div>

+ <div class="paragraph">

+ <p>Web applications commonly require the use of a database server. This wiki contains information on installing and configuring <a href="https://fedoraproject.org/wiki/PostgreSQL">PostgreSQL</a> and <a href="https://fedoraproject.org/wiki/MariaDB">MariaDB</a> on Fedora.</p>

+ </div>

+ </div>

+ </div>

+ <div class="sect1">

+ <h2 id="configuring-apache-httpd"><a class="anchor" href="#configuring-apache-httpd"></a>Configuring Apache HTTPD</h2>

+ <div class="sectionbody">

+ <div class="paragraph">

+ <p><code>/etc/httpd/conf/httpd.conf</code> is the main Apache configuration file. Custom confirguration files are specified under <code>/etc/httpd/conf.d/*.conf</code>. If the same settings are specified in both <code>/etc/httpd/conf/httpd.conf</code> and a <code>.conf</code> file in <code>/etc/httpd/conf.d/</code>, the setting from the <code>/etc/httpd/conf.d/</code> file will be used.</p>

+ </div>

+ <div class="paragraph">

+ <p>Files in <code>/etc/httpd/conf.d/</code> are read in alphabetical order: a setting from <code>/etc/httpd/conf.d/z-foo.conf</code> will be used over a setting from <code>/etc/httpd/conf.d/foo.conf</code>. Similarly, a setting from <code>/etc/httpd/conf.d/99-foo.conf</code>, will be used over a setting from <code>/etc/httpd/conf.d/00-foo.conf</code>.</p>

+ </div>

+ <div class="paragraph">

+ <p>As a best practice, do not modify <code>/etc/httpd/conf/httpd.conf</code> or any of the <code>/etc/httpd/conf.d</code> files shipped by Fedora packages directly. If you make any local changes to these files, then any changes to them in newer package versions will not be directly applied. Instead, a <code>.rpmnew</code> file will be created, and you will have to merge the changes manually.</p>

+ </div>

+ <div class="paragraph">

+ <p>It is recommended to create a new file in <code>/etc/httpd/conf.d</code> which will take precedence over the file you wish to modify, and edit the required settings. For instance, to change a setting specified in <code>/etc/httpd/conf.d/foo.conf</code> you could create the file <code>/etc/httpd/conf.d/z-foo-local.conf</code>, and place your setting in that file.</p>

+ </div>

+ <div class="admonitionblock note">

+ <table>

+ <tr>

+ <td class="icon">

+ <i class="fa icon-note" title="Note"></i>

+ </td>

+ <td class="content">

+ <div class="paragraph">

+ <p>After making any changes to your server configuration, execute the following command:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre># apachectl reload</pre>

+ </div>

+ </div>

+ <div class="paragraph">

+ <p>Certain changes may require Apache to be fully restarted. To fully restart Apache, execute the following command:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre># systemctl restart httpd.service</pre>

+ </div>

+ </div>

+ </td>

+ </tr>

+ </table>

+ </div>

+ <div class="sect2">

+ <h3 id="enabling-access-to-web-applications"><a class="anchor" href="#enabling-access-to-web-applications"></a>Enabling access to web applications</h3>

+ <div class="paragraph">

+ <p>By default Fedora-packaged web applications are usually configured such that, access is allowed only from the localhost. This is defined by the file <code>/etc/httpd/conf.d/webapp.conf</code> which contains the following settings:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre>&lt;Directory /usr/share/webapp&gt;

+     &lt;IfModule mod_authz_core.c&gt;

+         # Apache 2.4

+         Require local

+     &lt;/IfModule&gt;

+     &lt;IfModule !mod_authz_core.c&gt;

+         # Apache 2.2

+         Order Deny,Allow

+         Deny from all

+         Allow from 127.0.0.1

+         Allow from ::1

+     &lt;/IfModule&gt;

+ &lt;/Directory&gt;</pre>

+ </div>

+ </div>

+ <div class="paragraph">

+ <p>Before allowing general access to the webapp, ensure to do the following:</p>

+ </div>

+ <div class="ulist checklist">

+ <ul class="checklist">

+ <li>

+ <p><i class="fa fa-check-square-o"></i> Webapp has been configured correctly</p>

+ </li>

+ <li>

+ <p><i class="fa fa-check-square-o"></i> Administration interface and other sensitive areas are not accessible without appropriate authentication</p>

+ </li>

+ <li>

+ <p><i class="fa fa-check-square-o"></i> Database configuration is secure, if the application uses a database</p>

+ </li>

+ </ul>

+ </div>

+ <div class="paragraph">

+ <p>To broaden access to the application, create a file <code>/etc/httpd/conf.d/z-webapp-allow.conf</code>. To allow access to all systems on a typical local network, add the following lines into the file:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre>&lt;Directory /usr/share/webapp&gt;

+     &lt;IfModule mod_authz_core.c&gt;

+         # Apache 2.4

+         Require local

+         Require ip 192.168.1

+     &lt;/IfModule&gt;

+     &lt;IfModule !mod_authz_core.c&gt;

+         # Apache 2.2

+         Order Deny,Allow

+         Deny from all

+         Allow from 127.0.0.1

+         Allow from ::1

+         Allow from 192.168.1

+     &lt;/IfModule&gt;

+ &lt;/Directory&gt;</pre>

+ </div>

+ </div>

+ <div class="paragraph">

+ <p>Once the application is correctly configured, add the following configuration to allow access from any host:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre>&lt;Directory /usr/share/webapp&gt;

+     &lt;IfModule mod_authz_core.c&gt;

+         # Apache 2.4

+         Require all granted

+     &lt;/IfModule&gt;

+     &lt;IfModule !mod_authz_core.c&gt;

+         # Apache 2.2

+         Order Deny,Allow

+         Allow from all

+     &lt;/IfModule&gt;

+ &lt;/Directory&gt;</pre>

+ </div>

+ </div>

+ </div>

+ <div class="sect2">

+ <h3 id="opening-firewall-ports"><a class="anchor" href="#opening-firewall-ports"></a>Opening firewall ports</h3>

+ <div class="admonitionblock important">

+ <table>

+ <tr>

+ <td class="icon">

+ <i class="fa icon-important" title="Important"></i>

+ </td>

+ <td class="content">

+ This exposes your computer to the Internet and potential attackers. Secure your system and your Apache installation properly before exposing your server to the Internet.

+ </td>

+ </tr>

+ </table>

+ </div>

+ <div class="paragraph">

+ <p>Apache uses port 80 for plain http connections and port 443 for TLS/SSL connections by default. To make this service available from other computers or the Internet, allow Apache through the firewall using any one the following commands:</p>

+ </div>

+ <div class="paragraph">

+ <p>To allow Apache through the firewall at each boot:</p>

+ </div>

+ <div class="ulist">

+ <ul>

+ <li>

+ <p>For plain HTTP connections:</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre># firewall-cmd --permanent --add-service=http</pre>

+ </div>

+ </div>

+ </li>

+ <li>

+ <p>For TLS/SSL connections:</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre># firewall-cmd --permanent --add-service=https</pre>

+ </div>

+ </div>

+ </li>

+ </ul>

+ </div>

+ <div class="paragraph">

+ <p>To allow Apache through the firewall instantly:</p>

+ </div>

+ <div class="ulist">

+ <ul>

+ <li>

+ <p>For plain HTTP connections:</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre># firewall-cmd --add-service=http</pre>

+ </div>

+ </div>

+ </li>

+ <li>

+ <p>For TLS/SSL connections:</p>

+ <div class="listingblock">

+ <div class="content">

+ <pre># firewall-cmd --add-service=https</pre>

+ </div>

+ </div>

+ </li>

+ </ul>

+ </div>

+ <div class="admonitionblock note">

+ <table>

+ <tr>

+ <td class="icon">

+ <i class="fa icon-note" title="Note"></i>

+ </td>

+ <td class="content">

+ If your server is running in a network with a NAT router, you will also need to configure your router to forward the HTTP and HTTPS ports to your server, if you wish to allow access from outside your local network.

+ </td>

+ </tr>

+ </table>

+ </div>

+ </div>

+ <div class="sect2">

+ <h3 id="disabling-test-page"><a class="anchor" href="#disabling-test-page"></a>Disabling Test Page</h3>

+ <div class="paragraph">

+ <p>To disable the test page, comment out all the lines in the file <code>/etc/httpd/conf.d/welcome.conf</code> using <code>#</code> as follows:</p>

+ </div>

+ <div class="listingblock">

+ <div class="content">

+ <pre># &lt;LocationMatch "^/+$"&gt;

+ #    Options -Indexes

+ #    ErrorDocument 403 /.noindex.html

+ # &lt;/LocationMatch&gt;

+ 

+ # &lt;Directory /usr/share/httpd/noindex&gt;

+ #    AllowOverride None

+ #    Require all granted

+ # &lt;/Directory&gt;

+ 

+ # Alias /.noindex.html /usr/share/httpd/noindex/index.html</pre>

+ </div>

+ </div>

+ <h2 id="_additional_resources" class="discrete">Additional resources</h2>

+ <div class="ulist">

+ <ul>

+ <li>

+ <p><a href="https://httpd.apache.org/docs/current/">Apache Documentation</a></p>

+ </li>

+ <li>

+ <p><a href="https://httpd.apache.org/docs/current/getting-started.html">Apache "Getting Started"</a></p>

+ </li>

+ <li>

+ <p><a href="https://httpd.apache.org/docs/current/ssl/">Apache TLS/SSL documentation</a></p>

+ </li>

+ <li>

+ <p><a href="https://httpd.apache.org/docs/current/misc/security_tips.html">Apache security tips</a></p>

+ </li>

+ <li>

+ <p><a href="https://fedoraproject.org/wiki/OwnCloud">OwnCloud</a>

+ :!context:</p>

+ </li>

+ </ul>

+ </div>

+ </div>

+ </div>

+ </div>

+ </article>

+ <div id="contributing">

+     <p class="contribute">Want to help? <a href="https://docs.fedoraproject.org/en-US/fedora-docs/contributing/">Learn how to contribute to Fedora Docs.</a></p>

+ </div>  </main>

+ </div>

+ <footer class="footer">

+   <p>All Fedora Documentation content available under <a href="http://creativecommons.org/licenses/by-sa/3.0/legalcode">CC-BY-SA 3.0</a> or, when specifically noted, under another <a href="https://fedoraproject.org/wiki/Licensing:Main">accepted</a> free and open content license.</p>

+   <p>Last build: </p>

+ </footer>

+ <script src="../../_/js/site.js"></script>

+ <script src="../../_/js/vendor/highlight.js"></script>

+ <script>hljs.initHighlighting()</script>

+   </body>

+ </html>