![cmd 中的 httpd 指令不適用於 Apache](https://rvso.com/image/1585741/cmd%20%E4%B8%AD%E7%9A%84%20httpd%20%E6%8C%87%E4%BB%A4%E4%B8%8D%E9%81%A9%E7%94%A8%E6%96%BC%20Apache.png)
每個人都說您可以透過執行以下命令將 Apache 安裝為服務:
httpd.exe -n "servicenameherexd"
但cmd
輸出這個:
'httpd.exe' is not recognized as an internal or external command, operable program or batch file.
我正在尋找其他方法來執行此操作或如何修復此方法。謝謝! :)
答案1
出現此問題的原因可能是它httpd.exe
不在您的 Windows PATH/Path 變數中。
若要將目前版本的 Apache(即 Apache 2.4.x)安裝為 Windows 上的服務:
以管理員身分導覽至所在資料夾
httpd.exe
(通常位於bin
主 Apache 安裝的資料夾下)。去做這個:打開跑步...Windows「開始」功能表下的對話方塊並鍵入cmd --> Ctrl+ Shift+Enter。這將開啟一個管理命令視窗(即帶有 UAC 提示符號)。
使用前。
cd c:\path\to\Apache\bin
導航到您的 Apache 安裝bin
資料夾。
運行前。
httpd.exe -k install -n "Apache2.4"
將 Apache 安裝為 Windows 服務。
然後您可以使用 ex。httpd.exe -k start -n "Apache2.4"
一旦安裝(根據需要)從相同視窗啟動 Apache 服務。
注意事項
為了避免問題,您應該始終使用
Apach2.4
作為服務名稱,除非您有令人信服的理由不這樣做。您可能需要使用 ex 停止任何先前的 Apache 服務。
httpd.exe -k stop -n "Apache2.4"
。您應該能夠使用 ex 卸載 Apache 服務。
httpd.exe -k uninstall -n "Apache2.4"
。
欲了解更多信息,請參閱在 Microsoft Windows 上使用 Apache HTTP 伺服器。