{"id":3603,"date":"2019-02-14T22:52:06","date_gmt":"2019-02-14T17:22:06","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=3603"},"modified":"2026-10-08T12:27:37","modified_gmt":"2026-10-08T06:57:37","slug":"enable-mod_filter-in-apache-on-centos","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/enable-mod_filter-in-apache-on-centos\/","title":{"rendered":"Enable mod_filter in Apache on CentOS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Post Date:<\/strong> February 14, 2019 <br><strong>Last Updated:<\/strong> October 08, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This guide explains how to enable mod_filter in Apache on CentOS. Apache ships with the filter module, but it isn&#8217;t loaded by default \u2014 so if you use a filter directive like <code>FilterDeclare<\/code> in your site configuration without it, you&#8217;ll see an error like:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Invalid command 'FilterDeclare', perhaps misspelled or defined by a module not included in the server configuration\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The steps below apply equally to AlmaLinux, Rocky Linux, and other RHEL-compatible distributions, since CentOS 7 itself is past end-of-life.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you enable mod_filter in Apache on CentOS, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A CentOS (or RHEL-compatible) server with Apache (<code>httpd<\/code>) installed<\/li>\n\n\n\n<li>Root or sudo access<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Architecture<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apache loads its functionality through <strong>modules<\/strong>, each declared with a <code>LoadModule<\/code> line in its configuration<\/li>\n\n\n\n<li>A directive like <code>FilterDeclare<\/code> belongs to <code>mod_filter<\/code> \u2014 if that module isn&#8217;t loaded, Apache doesn&#8217;t recognize the directive and throws the error above<\/li>\n\n\n\n<li>Loading the module makes the directive available, with no other changes needed<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The diagram below shows how to enable mod_filter in Apache on CentOS: without the module loaded, the directive fails; once the <code>LoadModule<\/code> line is in place, it&#8217;s recognized.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/Apache-Filter-Configuration-Workflow-1.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"512\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/Apache-Filter-Configuration-Workflow-1-1024x512.png\" alt=\"\" class=\"wp-image-12164\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/Apache-Filter-Configuration-Workflow-1-1024x512.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/Apache-Filter-Configuration-Workflow-1-300x150.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/Apache-Filter-Configuration-Workflow-1-768x384.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/Apache-Filter-Configuration-Workflow-1-1536x768.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/Apache-Filter-Configuration-Workflow-1.png 1774w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">For the full directive reference, see the <a href=\"https:\/\/httpd.apache.org\/docs\/2.4\/mod\/mod_filter.html\" target=\"_blank\" rel=\"noopener\">official Apache mod_filter documentation<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Enable mod_filter in Apache on CentOS<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Check Whether the Module Line Already Exists<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On CentOS 7 and later, module loading is split across files in <code>\/etc\/httpd\/conf.modules.d\/<\/code>, rather than all living in the main <code>httpd.conf<\/code>. The line may already be there, just commented out:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">grep -r \"filter_module\" \/etc\/httpd\/conf.modules.d\/ \/etc\/httpd\/conf\/httpd.conf\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you see <code>#LoadModule filter_module modules\/mod_filter.so<\/code> (commented out), simply remove the <code>#<\/code> instead of adding a second line \u2014 duplicate <code>LoadModule<\/code> lines can cause warnings or errors.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Add the LoadModule Line (If Not Already Present)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If the line isn&#8217;t there, this is the change that actually lets you enable mod_filter in Apache on CentOS:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">vi \/etc\/httpd\/conf.modules.d\/00-base.conf\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">LoadModule filter_module modules\/mod_filter.so\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The original guide added this directly to <code>httpd.conf<\/code>. That works, but on current CentOS versions, keeping module declarations in <code>conf.modules.d\/<\/code> follows the distribution&#8217;s intended layout and is easier to maintain.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">3. Test the Configuration<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apachectl -t\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see <code>Syntax OK<\/code>. Catching a mistake here is much safer than discovering it after a restart takes Apache down.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Reload Apache<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl reload httpd\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The original used <code>service httpd graceful<\/code>. <code>graceful<\/code> isn&#8217;t a standard action for the <code>service<\/code> command on systemd-based systems like CentOS 7+ \u2014 <code>systemctl reload httpd<\/code> is the correct way to reload Apache&#8217;s configuration without dropping active connections. Alternatively, <code>apachectl graceful<\/code> does the same thing directly.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">5. Verify the Module Loaded<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apachectl -t -D DUMP_MODULES | grep filter_module\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Expected output:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> filter_module (shared)\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Learning how to enable mod_filter in Apache on CentOS comes down to checking whether its <code>LoadModule<\/code> line already exists (commented out), adding or uncommenting it in <code>conf.modules.d\/<\/code>, testing the configuration, and reloading Apache with <code>systemctl reload httpd<\/code>. Always run <code>apachectl -t<\/code> before reloading \u2014 it&#8217;s the simplest way to avoid taking a live server down over a typo.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why did &#8220;service httpd graceful&#8221; not work for me?<\/strong> <code>graceful<\/code> isn&#8217;t a standard action for <code>service<\/code> on systemd systems \u2014 use <code>systemctl reload httpd<\/code> or <code>apachectl graceful<\/code> instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Will adding a duplicate LoadModule line break Apache?<\/strong> It can cause warnings or errors, which is why Step 1 has you check whether the line already exists, commented out, before adding anything new.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Do I need to restart Apache fully to enable mod_filter in Apache on CentOS, or is a reload enough?<\/strong> A reload is enough \u2014 it applies the new module without dropping active connections, unlike a full restart.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/apache-password-authentication-centos\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Set Up Apache Password Authentication on CentOS<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/installing-modsecurity-with-owasp-crs-on-apache-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Install ModSecurity and OWASP CRS on Apache Ubuntu<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to Our Technology Experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Configuring Apache modules or tuning your web server setup? Our team can help with Apache configuration, performance tuning, and ongoing server support.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/contact\">Connect with our technology experts.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: February 14, 2019 Last Updated: October 08, 2026 Introduction This guide explains how to enable mod_filter in Apache [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[278,161],"class_list":["post-3603","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-apache","tag-centos","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-W7","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=3603"}],"version-history":[{"count":1,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3603\/revisions"}],"predecessor-version":[{"id":12165,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3603\/revisions\/12165"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}