2012-07-19 145 views
13

我在Windows 7上安裝了XAMPP。我需要每天停止並啓動Apache多次。XAMPP - 快速重啓apache的方法?

目前,我通過打開Xampp控制面板,單擊'停止'(旁邊的'Apache'),等待它停止,然後單擊'開始'來做到這一點。

enter image description here

我非常希望能夠更快地做到這一點 - 像右擊XAMPP圖標,並選擇「重新啓動Apache的。或者,甚至更好,只需一個重新啓動Apache的快捷鍵即可。

我知道有兩個bat文件與Xampp - apache_stop.bat和apache_start.bat。我試圖利用這些來獲得我想要的。但是,當你運行apache_start.bat時,你會得到一個你無法擺脫的cmd窗口。我無法以這種方式默默地啓動Apache。

因此,基本上我希望能夠完全默默地快速重啓Apache(單擊/快捷鍵)。

在此先感謝。

回答

18

複製apache_start.bat並將其重命名爲apache_restart.bat

改線apache\bin\httpd.exeapache\bin\httpd.exe -k restart

瞧,你去那裏與你重新啓動腳本。 ,你也可以給它一個捷徑。

+1

謝謝,這工作得很好。我選擇了這個答案,因爲它允許我爲它分配一個AutoHotKey/Windows快捷鍵,並且我可以從一個PHP腳本運行它。 – 2012-07-19 11:00:49

+0

+1,好點的Danny Connell。 – Ben 2012-07-20 00:05:44

+0

在這種情況下,您不必始終保持apache_start.bat窗口處於打開狀態。大! – kachar 2012-10-18 23:25:19

3

如果您的系統托盤中有Apache服務監視器,您可以打開它(右鍵單擊,我想?)並單擊「重新啓動Apache」。

如果它不在系統托盤中,可以在Apache安裝的/bin文件夾中找到它(稱爲ApacheMonitor.exe)。我建議在「啓動」文件夾中製作一個快捷方式。

+0

重啓oneclick.Get軟件Apache的一個windows軟件這也偉大工程,謝謝! – 2012-07-19 10:54:38

1

對於我來說,在版本3.2.2的第一個答案沒有奏效。

我把兩個apache_start.batapache_stop.bat文件的腳本放在一起。

@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