我们如何在同一台机器上运行两个 Apache Http Server 实例 Windows 7
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16959839/
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
How we can run two instance of Apache Http Server on same machine Windows 7
提问by dinu0101
How we can run two instance of Apache Http Server on same machine Windows 7
我们如何在同一台机器上运行两个 Apache Http Server 实例 Windows 7
I want to configure 2 apache http servers and 3 tomcat server on window7 machine.
我想在window7机器上配置2个apache http服务器和3个tomcat服务器。
Currently I have done configuration with 1 http server and 2 or more tomcat server, but unable to do configuration of 2 http servers on same windows machine.Whenever I start second time of http server(2nd instance) then is says like this:
目前我已经完成了 1 个 http 服务器和 2 个或更多 tomcat 服务器的配置,但无法在同一台 Windows 机器上配置 2 个 http 服务器。每当我第二次启动 http 服务器(第二个实例)时,就会这样说:
httpd: Could not reliably determine the server's fully qualified domain name,
using 172.17.124.181 for ServerName (OS 10048)Only one usage of each socket
address (protocol/network address/port) is normally permitted.:
make_sock: could not bind to address 0.0.0.0:80 no listening sockets available,
shutting down Unable to open logs
Please let me know how I can I run two instances of HTTP servers on same windows machine. Help is appreciated. Thanks in advance.
请让我知道如何在同一台 Windows 机器上运行两个 HTTP 服务器实例。帮助表示赞赏。提前致谢。
回答by Shreyas Kothari
Copy your current Apache files to another folder and modify the httpd.conf file. Change two things: ServerRoot : give the path of the new folder where you have copied your apache files. Listen: Give a new port number other than 80. It will be better if you give a port number larger than 1024.
将您当前的 Apache 文件复制到另一个文件夹并修改 httpd.conf 文件。更改两件事: ServerRoot :提供复制 apache 文件的新文件夹的路径。监听:给一个80以外的新端口号,给一个大于1024的端口号会更好。
Make sure you have not set the environment path for httpd.exe. if you have just remove it.
确保您没有为 httpd.exe 设置环境路径。如果你刚刚删除它。
Now in the command prompt navigate to the bin folder of new server. then type the following command. httpd.exe -k install -n "New Apache" -f "C:/path/to/httpd.conf"(Of the new server).
现在在命令提示符下导航到新服务器的 bin 文件夹。然后键入以下命令。 httpd.exe -k install -n "New Apache" -f "C:/path/to/httpd.conf"(新服务器的)。
Once you execute this command successfully, you'll find a new service named "New Apache" in services.msc. Start that service and in browser try to run the server with the new port number that you have given in the httpd.conf file of the new server.
成功执行此命令后,您将在 services.msc 中找到一个名为“New Apache”的新服务。启动该服务并在浏览器中尝试使用您在新服务器的 httpd.conf 文件中提供的新端口号运行服务器。
Mostly that should work. But in case it doesn't execute the following command
大多数情况下应该可以。但万一它不执行以下命令
httpd.exe -k config -n "New Apache" -f "C:\path\to\httpd.conf
httpd.exe -k config -n "新 Apache" -f "C:\path\to\httpd.conf
Hope that helps!
希望有帮助!
回答by Steven M. Wurster
You'll have to run the 2nd Apache instance on a port other than port 80. Find the Listen directive in the httpd.conf file for the 2nd Apache instance and change the port.
您必须在端口 80 以外的端口上运行第二个 Apache 实例。在第二个 Apache 实例的 httpd.conf 文件中找到 Listen 指令并更改端口。
回答by Vikas
A 'Listen directive' tells a server to accept incoming requests on the specified ports, and a server can also be made to listen to address-and-port combinations.
“侦听指令”告诉服务器接受指定端口上的传入请求,并且还可以使服务器侦听地址和端口组合。
If you specify a port number in the Listen directive, the server listens to that port on all interfaces. If you specify an IP address as well as a port, the server will listen on that port and interface.
如果在 Listen 指令中指定端口号,则服务器会在所有接口上侦听该端口。如果您指定 IP 地址和端口,服务器将侦听该端口和接口。
For example, if you were to make the server accept connections on both port 80
and port 8000
on all the interfaces, you could try this:
例如,如果您要让服务器接受所有接口上的端口80
和端口8000
上的连接,您可以尝试以下操作:
Listen 80
Listen 8000
... but if you want to make the server accept connections on port 80
for one interface (e.g. 198.0.1.1
), and port 8000
on the other (e.g. 198.0.2.2
), you would write something like this:
...但如果您想让服务器接受80
一个接口(例如198.0.1.1
)的端口连接和另一个接口的端口8000
(例如198.0.2.2
),您可以编写如下内容:
Listen 198.0.1.1:80
Listen 198.0.2.2:8000