- How Do I Enable Apache Modules From The Command Line In RedHat?
- A2enmod Not Found
- Enable Apache Modules In CentOS By Command Line
This article will help you to enable HTTP/2.0 in Apache web server on CentOS / Red Hat/ Debian and Ubuntu systems. Install or Update Apache. HTTP/2 protocol supported over Apache version =2.4.17. So make sure that your Apache version supporting HTTP/2 protocol. If you have not installed Apache or using older version upgrade it first.
Last updated: 15 Feb 2018
- Install / Initial Config. Install CentOS (01) Download CentOS 7 (02) Install CentOS 7; Initial Settings (01) Add an User (02) FireWall & SELinux (03) Configure Networking (04) Configure Services (05) Update System (06) Add Repositories (07) Configure vim (08) Configure sudo (09) Cron's Setting; NTP / SSH Server. NTP Server (01) Configure NTP.
- This manual page documents briefly the a2enmod and a2dismod commands. A2enmod is a script that enables the specified module within the apache2 configuration.
Apache version 2.4.17
introduced HTTP/2 support. If your server is running Apache version below this version, you need to upgrade Apache to the latest version first.
mod_http2
module is rather new, but is finally marked stable. There have been multiple reported security vulnerabilities in 2016 and 2017. 1. mod_http2
module that comes with Apache versions prior to 2.4.26 are insecure. Please make sure to use Apache version 2.4.26 or later.Upgrade Apache
Depending on the server operating system, you may be able to download the compiled latest version.
Windows
You can either compile Apache yourself, or download compiled Windows binaries. We recommend Apache Lounge builds.
Ubuntu / Debain
Apache web server distributed in default software repositories of Ubuntu and Debian do not include mod_http2
needed to enable HTTP/2 functionality. You will need to add a third-party package source with latest Apache version that also inludes mod_http2
.
apachectl -v
command will reveal your upgraded Apache version. This will be 2.4.29
or later.CentOS / RHEL
Both CentOS and RHEL default repositories come with Apache versions around2.4.6
. Apache official web sitehas information about building the latest Apache server.Enable HTTP/2 module
Apache's HTTP/2 support comes from themod_http2
module. Enable it from:If above commands do not work in your system (which is likely the case in CentOS/RHEL), use LoadModule
directive in httpd
configuration directory to enable http2
module.Add HTTP/2 Support
We highly recommend you enable HTTPS support for your web site first. Most web browser simply do not support HTTP/2 overplain text. Besides, there are no excuses to not use HTTPS anymore.HTTP/2 can be enabled site-by-site basis. Locate your web site's Apache virtual host configuration file, and add the followingright after the opening<VirtualHost>
tag:Overall, your configuration file should look something like this:After the changes, don't forget to reload/restart Apache.Push resources
Apache supports HTTP/2 Push feature as well. After enabling Apache HTTP/2, you can add push support simply by settingHTTPLink
headers. You can emit them from either/both the Apache configuration file, or from your application.Above is an example header that would trigger Apache to push the /assets/styles.css
and/assets/scripts.scc
files. Refer to your application code on how to emit HTTP headers.If you would like to make Apache add these headers, you can do so like this, using the mod_headers
module.Above example demonstrates Apache configuration that sets 2 Link
headers (you can have as many as you need).Supported browsers will decide to preload these resources if necessary.Troubleshooting
Apache 2.4.27, HTTP/2 not supported in prefork
Starting from Apache 2.4.27, the Apache MPM (Multi-Processing Module)prefork
no longer supports HTTP/2. This will be indicated in your Apache error log as follows:To fix this, select a different MPM:
event
or worker
. We highly recommend you to use the event
prefork.If you are using PHP, it is likely that PHP is integrated to Apache via the
mod_php
module, which requires the prefork
MPM. If you switch out from preform
MPM, you will need to use PHP as FastCGI
. To switch to php-fpm
, you can do as folllwing. Please note that this assumes you have PHP installed from ondrej/php repository on Ubuntu. The PHP package names could be different in other repositories. Change package name and apt-get
commands to match your PHP vendor and package manager.HTTP/2 not enabled on older TLS versions
Mozilla Firefox (among other browsers) does not enable HTTP/2 protocol unless the connection is made over TLS 1.2 andusing modern cipher suits. This is not a technical limitation, but rather a safety precaution. Make sure your that yoursite supports TLS 1.2, and modern cipher suits with AES/CHACHA20 with forward-secrecy key exchanges. In turn, Apachedoes not try to establish an HTTP/2 connection with connections over older cipher configurations either. you can forceApache attempt HTTP/2 upgrade with the following directive, but it will not be as effective because browsers do notsupport HTTP/2 from their end anyway.HTTP 421: Misdirected Request errors
HTTP/2 is designed to make parralel requests to the server over the same session. If two connections use same TLScertificate and remote IP address, browsers will attempt to reuse an existing connection. Apache can correctly servesuch requests even if those requests belong to different Virtual Hosts. However, if you have different TLS configuration(protocol, client verification, or cipher suits), Apache will reject such requests with an HTTP 421: Misdirected Request error.To prevent this, make sure you keep same TLS settings for all Virtual Hosts that you serve a particular site in.Foot notes
Reported mod_http2
-related security vulnerabilities are as follows.
The preferred way of installing Icinga Web 2 is to use the official package repositories depending on which operatingsystem and distribution you are running.
In case you are upgrading from an older version of Icinga Web 2please make sure to read the upgrading sectionthoroughly.
Source and automated setups are described inside the advanced topicschapter.
Installing Requirements ¶
- Icinga 2 with the IDO database backend (MySQL or PostgreSQL)
- A web server, e.g. Apache or Nginx
- PHP version >= 5.6.0
- The following PHP modules must be installed: cURL, gettext, intl, mbstring, OpenSSL and xml
- LDAP PHP library when using Active Directory or LDAP for authentication
- MySQL or PostgreSQL PHP libraries
Installing Icinga Web 2 from Package ¶
Official repositories (support matrix):
Distribution | Repository |
---|---|
Debian | Icinga Repository |
Ubuntu | Icinga Repository |
RHEL/CentOS | Icinga Repository |
openSUSE | Icinga Repository |
SLES | Icinga Repository |
Community repositories:
Distribution | Repository |
---|---|
Gentoo | Upstream |
FreeBSD | Upstream |
ArchLinux | Upstream |
Alpine Linux | Upstream |
Packages for distributions other than the ones listed above may also be available.Please contact your distribution packagers.
Setting up Package Repositories ¶
You need to add the Icinga repository to your package management configuration for installing Icinga Web 2.If you’ve already configured your OS to use the Icinga repository for installing Icinga 2, you may skip this step.
Debian:
Ubuntu:
RHEL and CentOS 8:
RHEL and CentOS 7:
Fedora 31:
SLES 15/12:
openSUSE:
Alpine Linux:
INFO
Latest version of Icinga Web 2 is in the edge repository, which is the -dev branch.
RHEL/CentOS Notes ¶
How Do I Enable Apache Modules From The Command Line In RedHat?
The packages for RHEL/CentOS depend on other packages which are distributedas part of the EPEL repository.
CentOS 8 additionally needs the PowerTools repository for EPEL:
CentOS 7:
If you are using RHEL you need to additionally enable the optional
and codeready-builder
repository before installing the EPEL rpm package.
RHEL 8:
RHEL 7:
RHEL/CentOS 7 PHP SCL¶
Since version 2.5.0 we also require a newer PHP version than what is availablein RedHat itself. You need to enable the SCL repository, so that the dependenciescan pull in the newer PHP.
CentOS:
RedHat:
Make sure to also read the chapter on Setting up FPM.
Alpine Linux Notes ¶
The example provided suppose that you are running Alpine edge, which is the -dev branch and is a rolling release.If you are using a stable version, in order to use the latest Icinga Web 2 version you should “pin” the edge repository.In order to correctly manage your repository, please followthese instructions.
Installing Icinga Web 2 ¶
You can install Icinga Web 2 by using your distribution’s package manager to install the icingaweb2
package.Below is a list with examples for various distributions. The additional package icingacli
is necessary to follow further steps in this guide.The additional package libapache2-mod-php
is necessary on Ubuntu to makeIcinga Web 2 working out-of-the-box if you aren’t sure or don’t care about PHPFPM.
Debian:
Ubuntu:
RHEL/CentOS 8 and Fedora:
RHEL/CentOS 7
If you have SELinux enabled, the package icingaweb2-selinux
is also required.For RHEL/CentOS please read the package repositories notes.
SLES and openSUSE:
Alpine Linux:
For Alpine Linux please read the package repositories notes.
Installing the web server ¶
Depending on your OS you might have to install, and or configure the web server.We usually only require PHP as hard dependency.
We usually build on Apache httpd as the default web server, but you also can use nginx.
RedHat / CentOS / Fedora
Make sure to install httpd, start and enable it on boot.
Note for EPEL 7 and 8: Check the Setting up FPM chapter.
SUSE SLE / openSUSE
Make sure that web server is installed, and the required modules are loaded.
Debian / Ubuntu
Your web server should be up and running after the installation of Icinga Web 2.
Setting up FPM ¶
If you are on CentOS / RedHat, or just want to run Icinga Web 2 with PHP-FPM insteadof the Apache module.
Operating System | FPM configuration path |
---|---|
RedHat 8 | /etc/php-fpm.d/ |
RedHat 7 (with SCL) | /etc/opt/rh/rh-php71/php-fpm.d/ |
Fedora | /etc/php-fpm.d/ |
Debian/Ubuntu | /etc/php*/*/fpm/pool.d/ |
The default pool www
should be sufficient for Icinga Web 2.
On RedHat you need to start and enable the FPM service.
RedHat / CentOS 8 and Fedora:
RedHat / CentOS 7 (SCL package):
All module packages for PHP have this SCL prefix, so you can install adatabase module like this:
Depending on your web server installation, we might have installed orupdated the config file for icingaweb2 with defaults for FPM.
Check /etc/httpd/conf.d/icingaweb2.conf
or /etc/apache2/conf.d/icingaweb2.conf
.And *.rpm*
*.dpkg*
files there with updates.
Make sure that the FilesMatch
part is included for Apache >= 2.4. For Apache < 2.4 you have to include theLocationMatch
block.
Also see the example from icingacli:
Preparing Web Setup ¶
You can set up Icinga Web 2 quickly and easily with the Icinga Web 2 setup wizard which is available the first timeyou visit Icinga Web 2 in your browser. When using the web setup you are required to authenticate using a token.In order to generate a token use the icingacli
:
In case you do not remember the token you can show it using the icingacli
:
Preparing Web Setup on Debian/Ubuntu ¶
A2enmod Not Found
On Debian and derivates, you need to manually create a database and a database user prior to starting the web wizard.This is due to local security restrictions whereas the web wizard cannot create a database/user througha local unix domain socket.
You may also create a separate administrative account with all privileges instead.
Note: This is only required if you are using a local database as authentication type.
Starting Web Setup ¶
Finally visit Icinga Web 2 in your browser to access the setup wizard and complete the installation:/icingaweb2/setup
.
Note for Debian/Ubuntu
Enable Apache Modules In CentOS By Command Line
Use the same database, user and password details created above when asked.
The setup wizard automatically detects the required packages. In case one of them is missing,e.g. a PHP module, please install the package, restart your webserver and reload the setup page.
If you have SELinux enabled, please ensure to either have the selinux package for Icinga Web 2installed, or disable it.
Upgrading to FPM ¶
Valid for:
- RedHat / CentOS 7
Other distributions are also possible if preferred, but not included here.
Some upgrading work needs to be done manually, while we install PHP FPMas dependency, you need to start the service, and configure some things.
Please read Setting up FPM first.
php.ini settings you have tuned in the past needs to be migrated to a SCL installationof PHP.
Check these directories:
/etc/php.ini
/etc/php.d/*.ini
PHP settings should be stored to:
- RedHat / CentOS 7:
/etc/opt/rh/rh-php71/php.d/
Make sure to install the required database modules
RedHat / CentOS 7:
After any PHP related change you now need to restart FPM:
RedHat / CentOS 7:
If you don’t need mod_php for other apps on the server, you should disable it in Apache.
Disable PHP in Apache httpd:
You can also uninstall the mod_php package, or all non-SCL PHP related packages.