gpt4 book ai didi

java - 如何让 Tomcat 7 在 Windows Server 2008 的 80 端口上运行?

转载 作者:搜寻专家 更新时间:2023-11-01 03:22:08 25 4
gpt4 key购买 nike

我花了两天时间试图让它发挥作用。

当我第一次启动时Tomcat 7 ,它在端口 8080 上运行这是 Tomcat 的默认值。因此可以访问它但键入:http://localhost:8080/mydomain.com:8080 .

但我希望从端口 8080 移动到港口80所以我可以输入 mydomain.com并被定向到网页。

我已经禁用了可能在端口 80 上运行的所有额外服务例如 IIS、MSSQL、万维网发布等。

server.xml文件,我做了以下更改:

<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

然后当我启动服务器时,我在日志中得到了这个(尽管服务器启动了):

...
Dec 27, 2014 9:34:44 PM org.apache.coyote.AbstractProtocol init
SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-apr-80"]
java.lang.Exception: Socket bind failed: [730048] Only one usage of each socket address (protocol/network address/port) is normally permitted.
at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:453)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:646)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:978)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:821)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:638)
at org.apache.catalina.startup.Catalina.load(Catalina.java:663)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:280)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:454)

Dec 27, 2014 9:34:44 PM org.apache.catalina.core.StandardService initInternal
SEVERE: Failed to initialize connector [Connector[HTTP/1.1-80]]
org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-80]]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:821)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:638)
at org.apache.catalina.startup.Catalina.load(Catalina.java:663)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:280)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:454)
Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:980)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
... 12 more
Caused by: java.lang.Exception: Socket bind failed: [730048] Only one usage of each socket address (protocol/network address/port) is normally permitted.
at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:453)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:646)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:978)
... 13 more

Dec 27, 2014 9:34:44 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Dec 27, 2014 9:34:44 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 3310 ms
Dec 27, 2014 9:34:44 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 27, 2014 9:34:44 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.57
Dec 27, 2014 9:34:44 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Apache\tomcat\webapps\docs
Dec 27, 2014 9:34:46 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\Apache\tomcat\webapps\docs has finished in 1,985 ms
Dec 27, 2014 9:34:46 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Apache\tomcat\webapps\examples
Dec 27, 2014 9:34:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\Apache\tomcat\webapps\examples has finished in 1,234 ms
Dec 27, 2014 9:34:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Apache\tomcat\webapps\host-manager
Dec 27, 2014 9:34:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\Apache\tomcat\webapps\host-manager has finished in 453 ms
Dec 27, 2014 9:34:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Apache\tomcat\webapps\manager
Dec 27, 2014 9:34:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\Apache\tomcat\webapps\manager has finished in 313 ms
Dec 27, 2014 9:34:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Apache\tomcat\webapps\ROOT
Dec 27, 2014 9:34:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\Apache\tomcat\webapps\ROOT has finished in 156 ms
Dec 27, 2014 9:34:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Dec 27, 2014 9:34:48 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4282 ms

当我访问 url mydomain.com 时什么也看不见

我在这方面非常陌生 - 浏览了很多在线帖子并遵循了说明,但似乎没有任何效果。我之前已经完成了相同的步骤,而且效果非常好。

我现在必须做什么?请帮忙。

这是我在 netstat 上得到的

netstat result

最佳答案

一些其他应用正在使用端口 80。使用 netstart 进行本地端口扫描并打印可执行路径(此视频将提供帮助: https://www.youtube.com/watch?feature=player_detailpage&v=V3nWkr7v4-E#t=7 )

通常是 Skype(或其他聊天或点对点文件共享应用程序)。关闭 skype(退出不仅仅是注销,进程应该退出)然后启动 tomcat。然后可以重新启动 skype 它会在其他一些端口上正常工作。

此外,是否有任何防火墙条目阻止 Java 绑定(bind)到此端口?可以从您的防火墙规则中检查 - 如果您使用的是控制面板中的默认 Windows 防火墙。 https://www.youtube.com/results?search_query=widows+firewall+java+allow这些结果或常规搜索引擎中的相同术语将告诉您允许 Java 的步骤。通常 Windows 会在您第一次运行应用程序时询问。所以如果你说不,那么它会记住这一点。还需要具有管理员角色(登录/或提示用户)才能进行这些更改。对于某些问题也有助于打开管理控制台。右键单击 cmd.exe 并选择以管理员身份运行,对安全提示说是。

这个程序可能会有所帮助,将它保存到一个名为“PortCheck.java”的文件中

    class PortCheck{
public static void main(String []args) throws Exception{
String port = "80";
if(args.length > 0)port = args[0];
final int p = Integer.parseInt(port);
Thread t = new Thread(){
public void run(){

try{
java.net.ServerSocket s = new java.net.ServerSocket(p);
System.out.println("\nListening on port " + p);
s.accept();
}catch(Exception e){
System.out.println("Err " + e);
}
}
};
t.start();
Thread.sleep(2000);
System.out.println("Bye ");
System.exit(0);
}
}

编译它

javac c:\_your_path\PortCheck.java

并运行它:

java -cp c:\_your_path PortCheck

如果成功绑定(bind)到 80 会告诉你:

Listening on port 80 Bye

同样可以尝试443端口

关于java - 如何让 Tomcat 7 在 Windows Server 2008 的 80 端口上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27673761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com