httpd.conf फ़ाइल
httpd.conf Apache की main configuration file है -- वह जगह जहाँ आप Apache को बताते हैं कि किस port पर सुनना है, आपकी website की files कहाँ हैं, और इसे कैसे behave करना चाहिए। इस course का बाकी लगभग सब कुछ असल में इस file (या इसके include किए गए files) को edit करने के बारे में ही है।In this page:
इसे कहाँ ढूंढें
exact path आपके OS पर depend करता है: RHEL/CentOS पर /etc/httpd/conf/httpd.conf, Ubuntu/Debian पर /etc/apache2/apache2.conf (plus इसके include किए गए files), और एक XAMPP Windows install पर C:\xampp\apache\conf\httpd.conf। खासकर Ubuntu पर, apache2.conf ज़्यादातर बस दूसरी files को Include करता है -- असली interesting configuration ports.conf, sites-enabled/, और mods-enabled/ में बंटी होती है।
Core Directives
मुट्ठी भर directives file का ज़्यादातर हिस्सा बनाते हैं। ServerRoot वह base directory set करता है जिससे Apache दूसरे relative paths treat करता है। Listen set करता है कि Apache किस port(s) पर connections accept करे। DocumentRoot वह directory set करता है जहाँ से किसी given site की files serve होती हैं। ServerAdmin कुछ error pages पर दिखने वाला एक contact email set करता है। ServerName वह hostname set करता है जिससे Apache खुद को identify करता है।
Include और IncludeOptional
एक बड़ी file की जगह, Apache आपको Include path/to/file.conf या पूरी directory के लिए Include conf.d/*.conf से configuration को कई files में बांटने देता है। IncludeOptional वही काम करता है लेकिन अगर pattern से कोई files match न हों तो error नहीं देता। distros Virtual Hosts और modules को एक monolithic config की बजाय अपनी अलग files में structure ऐसे ही करते हैं।
Reload करने से पहले Config Test करना
Apache एक syntax checker देता है जिसे हर reload से पहले चलाना चाहिए: apachectl configtest (या Debian/Ubuntu पर apache2ctl configtest, या सीधे httpd -t)। यह हर included file parse करता है और actually server को restart किए बिना "Syntax OK" या problem की exact line report करता है।
systemctl reload apache2 से पहले apachectl configtest को आदत बना लें -- यहाँ एक typo पकड़ने में दो सेकंड लगते हैं; Apache के live server पर restart करने से मना करने के बाद इसे पकड़ने में कहीं ज़्यादा समय लगता है।उदाहरण: Core directives in httpd.conf
ServerRoot "/etc/httpd"
Listen 80
ServerAdmin [email protected]
ServerName example.com
DocumentRoot "/var/www/html"
# Pull in additional config split across other files
IncludeOptional conf.d/*.conf
{# 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). #}
- distro के लिए गलत file edit करना -- जैसे Ubuntu पर एक single httpd.conf की उम्मीद करना जब असली per-site config sites-available/ में रहता है, या RHEL पर इसका उल्टा।
- पहले
configtestचलाए बिना config change के बाद Apache reload करना, ताकि एक typo सिर्फ syntax check fail करने की बजाय पूरा server down कर दे। - यह न समझना कि directives inherited होते हैं और file में बाद में (या किसी included file में) ज़्यादा specific contexts से override हो सकते हैं -- order और scope दोनों मायने रखते हैं।
Chapter Quiz — Complete all 4 topics to unlock
0/4 topics done
Complete these topics first: