Danny Connell
Danny Connell

Reputation: 792

XAMPP - quick way to restart apache?

I have XAMPP installed on Windows 7. I need to stop and start Apache many times every day.

Currently, I do this by opening up the Xampp control panel, clicking 'Stop' (next to 'Apache'), waiting for it to stop, then clicking 'Start'.

enter image description here

Ideally I would like to be able to do this more quickly - something like right click the Xampp icon, and choosing 'Restart Apache'. Or, even better, just a shortcut key that restarts Apache.

I know that there are two bat files with Xampp - apache_stop.bat and apache_start.bat. I've tried utilising these to get want I want. However, when you run apache_start.bat, you get a cmd window that you can't get rid of. I couldn't find a way to start Apache silently in this way.

So, basically I want to be able to quickly restart Apache (one click/shortcut key), completely silently.

Thanks in advance.

Upvotes: 20

Views: 67961

Answers (4)

Samuel Gfeller
Samuel Gfeller

Reputation: 1000

@adrianthedev's version didn't work for (XAMPP v3.2.4) me but helped me find a solution. It's a lot less sophisticated as I don't know much about scripting but here it is and it worked for me:

@echo off
C:/xampp/apache/bin/httpd -k stop
C:/xampp/apache/bin/httpd -k start

Note: apache\logs\httpd.pid doesn't need to be deleted as it's done already by the httpd -k stop command.

Upvotes: 1

adrianthedev
adrianthedev

Reputation: 656

For me, with the version 3.2.2 the first answer didn't work.

I've put together a script from the two apache_start.bat and apache_stop.bat files.

@echo off
cd /D %~dp0

echo Apache 2 is stopping...

apache\bin\pv -f -k httpd.exe -q
if not exist apache\logs\httpd.pid GOTO exit
del apache\logs\httpd.pid

echo Apache 2 is re-starting ...

apache\bin\httpd.exe

if errorlevel 255 goto finish
if errorlevel 1 goto error
goto finish

:error
echo.
echo Apache konnte nicht gestartet werden
echo Apache could not be started
pause

:finish

Upvotes: 2

DKSan
DKSan

Reputation: 4197

Copy apache_start.bat and rename it to apache_restart.bat.

Change the line apache\bin\httpd.exe to apache\bin\httpd.exe -k restart

Voila, there you go with your restart script. and you can also give it a shortcut.

Upvotes: 27

Ben
Ben

Reputation: 57277

If you have the Apache service monitor in your system tray, you can just open that (right click, I think?) and click "restart Apache".

If it's not in your system tray, you can find it in the /bin folder of the Apache installation (called ApacheMonitor.exe). I'd recommend making a shortcut to it in the "Startup" folder.

Upvotes: 3

Related Questions