← Back to Apache Course | Chapter 3: Modules | Lesson 5 of 5

सामान्य Modules

rewrite/ssl/proxy/headers से आगे, Apache दर्जनों दूसरे modules के साथ आता है जो specific features add करते हैं -- यह lesson उनका एक tour है जिनसे आपका सामना सबसे ज़्यादा होगा।

Modules कैसे काम करते हैं

Apache का core अपने आप relatively कम करता है -- लगभग हर feature, यहाँ तक कि जो built-in जैसे लगते हैं, असल में LoadModule module_name modules/file.so से loaded एक module है। इस design से आप सिर्फ actually इस्तेमाल होने वाली चीज़ें load करके एक lean server रख सकते हैं, और यही कारण है कि किसी feature को enable करने का मतलब अक्सर पहले step के रूप में "module enable करो" होता है।

mod_dir और mod_autoindex

mod_dir DirectoryIndex directive supply करता है, जो decide करता है कि जब कोई request सिर्फ एक directory नाम बताए तो Apache automatically कौन सी filename (index.html, index.php, वगैरह) serve करे। mod_autoindex वह automatic file listing generate करता है जो Options Indexes on होने और कोई index file न होने पर दिखती है।

mod_deflate और mod_expires

mod_deflate responses को भेजने से पहले compress करता है (Performance chapter में covered)। mod_expires file type और age के आधार पर automatically Expires/Cache-Control headers generate करता है, mod_headers से हाथ से set करने का एक alternative।

mod_php / PHP-FPM, और mod_wsgi

Historically, mod_php PHP को सीधे Apache process के अंदर चलाता था; modern setups अक्सर PHP-FPM को एक अलग process की तरह चलाते हैं और mod_proxy_fcgi से connect करते हैं, जो बेहतर scale और isolate करता है। mod_wsgi Python web apps के लिए equivalent काम करता है, एक WSGI application (जैसे Django या Flask) को Gunicorn को proxy करने के alternative के तौर पर सीधे Apache के अंदर embed करते हुए।

क्या Loaded है यह Check करना

apachectl -M (या Debian/Ubuntu पर apache2ctl -M) हर currently loaded module list करता है -- यह check करने का सबसे तेज़ तरीका कि किसी directive को चाहिए होने वाला module actually active है या नहीं, इससे पहले कि directive को debug करने में समय बिताया जाए।

Note: जब भी कोई directive चुपचाप ignore होती लगे, apachectl -M | grep rewrite चलाएं (किसी भी module नाम को swap करें) -- अक्सर वजह बस यह होती है कि इसके पीछे वाला module कभी loaded ही नहीं हुआ।

उदाहरण: Listing loaded modules

apacheconf
apachectl -M

# Example output (truncated):
# core_module (static)
# rewrite_module (shared)
# ssl_module (shared)
# proxy_module (shared)
# headers_module (shared)
{# Flagged by hand after confirming a runner can't handle this example (a shell command / go.mod file stored as a TopicExample, a language feature the configured runner version doesn't support, or output that blows a runner's sandbox limit) -- see TopicExample.norun. Never render the run button for these, regardless of language, since it would just fail at execute_code (or worse, hang the Judge0 queue on a submission that can never finish cleanly). #}

⚠️ This example can't run in the browser editor. Try it in your own local environment instead.

{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह check किए बिना कि module loaded है, किसी specific module से belong करने वाली directive लिखना -- Apache इसे बस ignore कर सकता है, या "invalid command" error के साथ start होने से मना कर सकता है।
  2. एक नए setup के लिए अभी भी पुराना mod_php model चलाना, जब mod_proxy_fcgi के जरिए PHP-FPM आमतौर पर modern Apache पर PHP processes को बेहतर scale और isolate करता है।
  3. यह मान लेना कि हर Apache feature "core" server का हिस्सा है, जबकि इनमें से ज़्यादातर -- directory indexes जितनी basic चीज़ों समेत -- असल में अलग loadable modules हैं।
चैप्टर सारांश
  • mod_rewrite (URL rewriting), mod_ssl (HTTPS), mod_proxy (backend पर forward करना), और mod_headers (custom response headers) वे चार modules हैं जिन पर लगभग हर real Apache site depend करती है।
  • Apache का core जानबूझकर minimal है, और लगभग हर feature -- directory indexes, compression, PHP/Python execution -- एक अलग loadable module से आता है; apachectl -M दिखाता है कि अभी क्या active है।
🔒

Chapter Quiz — Complete all 5 topics to unlock

0/5 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.