httpd commands in cmd not working with Apache
This problem is likely occurring because httpd.exe
isn't in your Windows PATH/Path variable(s).
To install a current version of Apache (i.e. Apache 2.4.x) as a service on Windows:
-
Navigate as an Administrator to the folder where
httpd.exe
resides (typically under thebin
folder of your primary Apache installation). To do this:Open the Run... dialog box under the Windows Start menu and type cmd --> Ctrl + Shift + Enter. This will open an administrative command window (i.e with a UAC prompt).
Use ex.
cd c:\path\to\Apache\bin
to navigate to your Apache installationbin
folder.
Run ex.
httpd.exe -k install -n "Apache2.4"
to install Apache as a Windows service.
You can then use ex. httpd.exe -k start -n "Apache2.4"
to start the Apache service once it is installed (as needed) from the same window.
Caveats
To avoid issues, you should always use
Apach2.4
as the service name unless you have a compelling reason not to.You may need to stop any prior Apache service with ex.
httpd.exe -k stop -n "Apache2.4"
.You should be able to uninstall an Apache service with ex.
httpd.exe -k uninstall -n "Apache2.4"
.
For further information, see Using Apache HTTP Server on Microsoft Windows.
Related videos on Youtube
oggy333
Updated on September 18, 2022Comments
-
oggy333 over 1 year
Everyone says you install Apache as a service by running:
httpd.exe -n "servicenameherexd"
But
cmd
outputs this:'httpd.exe' is not recognized as an internal or external command, operable program or batch file.
I'm looking for other ways to do this or how to fix this method. Thanks! :)