Error restarting Apache on Windows machine via command line

I am having problems executing a command line to restart Apache on Windows.

The restart command I am executing is:

httpd.exe -k restart

Which I believe to be correct, but I get this back:

C:\Documents and Settings\Admin>httpd.exe -k restart
[Mon May 19 15:37:11.319818 2014] [mpm_winnt:error] [pid 2396:tid 1956] (OS 2)Th
e system cannot find the file specified. : AH00436: No installed service named
"Apache2.4".

Is there any way I can prevent this? I'm not familiar with running Apache on Windows.

Thank you in advance.

3

2 Answers

I was getting exactly the same error. I did the following steps.

  1. Firstly uninstall the service (as it was corrupted in my case) with command "httpd -k uninstall".(like cd path upto bin where Apache was installed previously).

  2. And then install Apache service by command "httpd -k install".

  3. you will get an error like this : httpd: Syntax error on line 37 of D:/set-up/Apache2.4.6/Apache2.4.6/Apache/conf/httpd.conf: ServerRoot must be a valid directory.(Replace it with the path where Apache2.4 is extracted - "D:/set-up/Apache2.4.6/Apache2.4.6").Replace it with your appropriate path.

    4.Restart Apache with this command "httpd -k restart".

The restart action causes Apache to reload and apply its configuration, without actually restarting the process or breaking any opened client connection, causing a so called "graceful reload". You can check it by yourself with Windows Task Manager, the Apache PID (Process ID) won't change after a restart.

However, any action triggered by the option -k (they are called signals), needs the Apache service to exist in Windows services list. Therefore, if you see this error message, there are only two possible causes:

Your Apache service does not exist

Then just create it with

httpd.exe -h install

Now you should be able to send the restart signal

httpd.exe -k restart

Your Apache service has a custom name

If the service exists, but has a custom name such as "My Awesome Apache Service", then you have to specify that name when you want to send it any signal.

So, if you have installed it with

httpd.exe -k install -n "My Awesome Apache Service"

you have to restart it with

httpd.exe -k restart -n "My Awesome Apache Service"

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like