← Back to Apache Course | Chapter 1: Introduction & Setup | Lesson 4 of 4

Windows पर Apache

Apache Windows में उस तरह built-in नहीं है जैसे यह Linux के लिए packaged है, इसलिए इसे install करने का मतलब है एक Windows build download करके इसे Windows service की तरह run करना। production use के लिए यह Linux जितना common नहीं है, लेकिन local development के लिए बहुत आम है।

Windows अलग क्यों है

apache.org से कोई official Apache binary Windows के लिए उस simple sense में नहीं है जैसे एक Linux package है -- Apache officially prebuilt Windows binaries बिल्कुल भी distribute नहीं करता। इसकी जगह, ज़्यादातर लोग या तो एक third-party build इस्तेमाल करते हैं (Apache Lounge एक जाना-पहचाना है) या, कहीं ज़्यादा आम तौर पर, XAMPP या WAMP जैसा एक bundled stack install करते हैं, जो Apache, MySQL, और PHP को एक आसान installer के साथ पैक करता है।

XAMPP से Install करना

XAMPP local development के लिए Windows पर Apache चलाने का सबसे आम तरीका है: apachefriends.org से installer download करें, इसे run करें, और यह C:\xampp\ जैसे एक folder के नीचे Apache, MySQL/MariaDB, PHP, और phpMyAdmin साथ में install कर देता है। XAMPP Control Panel आपको एक button से Apache start और stop करने देता है, जो Linux पर इस्तेमाल होने वाले systemctl commands की जगह लेता है।

Apache को Windows Service की तरह Run करना

(XAMPP की जगह) एक standalone Apache install आमतौर पर एक Windows service की तरह register किया जाता है ताकि यह automatically start हो। Apache के bin folder के अंदर एक elevated command prompt से:

`` httpd.exe -k install httpd.exe -k start httpd.exe -k stop httpd.exe -k restart ``

एक बार service की तरह installed होने के बाद, यह Windows Services app (services.msc) में भी दिखता है, जहाँ आप इसे किसी भी दूसरी Windows service की तरह start, stop, और boot पर launch होने के लिए set कर सकते हैं।

Windows पर Config File Locations

एक XAMPP install पर, main config file C:\xampp\apache\conf\httpd.conf पर है, और virtual hosts आमतौर पर C:\xampp\apache\conf\extra\httpd-vhosts.conf में होते हैं। एक standalone Apache Lounge-style install आपने जहाँ भी extract किया हो वहाँ same conf\httpd.conf layout रखता है। configuration *syntax* Linux जैसा ही identical है -- सिर्फ file paths (backslashes इस्तेमाल करना, और आमतौर पर एक C:\ drive) अलग होते हैं।

Note: Apache directives Windows पर भी config file के अंदर paths में forward slashes ही इस्तेमाल करते हैं (जैसे DocumentRoot "C:/xampp/htdocs"), भले ही Windows सामान्यतः backslashes इस्तेमाल करता हो।

आम Windows Port Conflicts

Windows पर port 80 अक्सर पहले से ही Internet Information Services (IIS), Skype, या "World Wide Web Publishing Service" द्वारा इस्तेमाल में होता है। अगर Apache port के इस्तेमाल में होने की error के साथ start होने में fail हो, तो या तो conflicting service रोकें या local development के लिए Apache की Listen directive को 8080 जैसे किसी दूसरे port पर बदल दें।

उदाहरण: Managing Apache as a Windows service

apacheconf
REM Run from an elevated Command Prompt inside Apache's bin\ folder
httpd.exe -k install
httpd.exe -k start
httpd.exe -k stop
httpd.exe -k restart
{# 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. एक official apache.org Windows installer की उम्मीद करना जैसे official Linux package होता है -- ज़्यादातर लोगों को Windows पर Apache XAMPP/WAMP या Apache Lounge जैसे third-party build से मिलता है।
  2. यह notice न करना कि IIS या Skype ने पहले से port 80 खोला हुआ है, फिर एक खराब Apache config मान लेना जबकि असली error "port already in use" है।
  3. httpd.conf directives के अंदर Windows-style backslash paths (C:\xampp\htdocs) इस्तेमाल करना, जबकि Apache का config syntax Windows पर भी forward slashes की उम्मीद करता है।
चैप्टर सारांश
  • Apache वह web server software है जो internet और आपकी website की files के बीच बैठकर requests, routing, और responses handle करता है; यह operating systems में अलग-अलग तरीके से install और run होता है लेकिन हर जगह same directive syntax से configure होता है।
  • Ubuntu/Debian पर, Apache apache2 package है जिसे systemctl और a2ensite/a2enmod से manage किया जाता है; RHEL-family Linux पर यह httpd है; Windows पर यह सबसे आम तौर पर XAMPP से install होता है या httpd.exe -k के साथ Windows service की तरह run होता है।
🔒

Chapter Quiz — Complete all 4 topics to unlock

0/4 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.