php XAMPP - 重新启动 apache 的快速方法?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11557101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 00:46:25  来源:igfitidea点击:

XAMPP - quick way to restart apache?

phpapachexampp

提问by Danny Connell

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

我在 Windows 7 上安装了 XAMPP。我每天需要多次停止和启动 Apache。

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

目前,我通过打开 Xampp 控制面板,单击“停止”(在“Apache”旁边),等待它停止,然后单击“开始”来执行此操作。

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.

理想情况下,我希望能够更快地执行此操作 - 例如右键单击 Xampp 图标,然后选择“重新启动 Apache”。或者,更好的是,只是一个重新启动 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.

我知道 Xampp 有两个 bat 文件 - apache_stop.bat 和 apache_start.bat。我试过利用这些来得到我想要的。但是,当您运行 apache_start.bat 时,您会看到一个无法摆脱的 cmd 窗口。我找不到以这种方式静默启动 Apache 的方法。

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

所以,基本上我希望能够完全无声地快速重启 Apache(一键/快捷键)。

Thanks in advance.

提前致谢。

回答by DKSan

Copy apache_start.batand rename it to apache_restart.bat.

复制apache_start.bat并重命名为apache_restart.bat.

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

将行更改apache\bin\httpd.exeapache\bin\httpd.exe -k restart

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

瞧,你的重启脚本就这样了。你也可以给它一个快捷方式。

回答by Ben

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

如果您的系统托盘中有 Apache 服务监视器,您只需打开它(我认为右键单击?)并单击“重新启动 Apache”。

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

如果它不在您的系统托盘中,您可以/bin在 Apache 安装文件夹(称为ApacheMonitor.exe)中找到它。我建议在“启动”文件夹中创建一个快捷方式。

回答by adrianthedev

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

对我来说,对于 3.2.2 版本,第一个答案不起作用。

I've put together a script from the two apache_start.batand apache_stop.batfiles.

我已经将两个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

回答by Sajjad Hossain Sagor

There is a windows software available now on github to restart apache on oneclick.Get the software from here Xampp OneClick Apache Restart Module

现在github上有一个windows软件可以在oneclick上重启apache。从这里获取软件Xampp OneClick Apache重启模块