无法在debian 7上的端口80上启动Jenkins

时间:2013-09-11 19:22:41

标签: linux jenkins port

我已经在debian 7上安装了Jenkins。现在我想在端口80上运行它,这样我就可以在我的本地LAN上输入http://jenkins而不是http://jenkins:8080(当前有效)。我已将文件/etc/default/jenkins修改为:

# port for HTTP connector (default 8080; disable with -1)
#HTTP_PORT=8080
#HTTP_PORT=88
HTTP_PORT=80

但是当我重新启动jenkins服务时:sudo service jenkins restart并尝试访问http://jenkins:80我只是得到一个空白/错误页面。日志说(/var/log/jenkins/jenkins.log ):

java.io.IOException: Failed to start a listener: winstone.HttpListener
    at winstone.Launcher.spawnListener(Launcher.java:229)
    at winstone.Launcher.<init>(Launcher.java:181)
    at winstone.Launcher.main(Launcher.java:384)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at Main._main(Main.java:288)
    at Main.main(Main.java:98)
Caused by: java.io.IOException: Failed to listen on port 80
    at winstone.HttpListener.getServerSocket(HttpListener.java:122)
    at winstone.HttpListener.start(HttpListener.java:75)
    at winstone.Launcher.spawnListener(Launcher.java:220)
    ... 8 more
Caused by: java.net.BindException: Permission denied
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:353)
    at java.net.ServerSocket.bind(ServerSocket.java:336)
    at java.net.ServerSocket.<init>(ServerSocket.java:202)
    at java.net.ServerSocket.<init>(ServerSocket.java:158)
    at winstone.HttpListener.getServerSocket(HttpListener.java:117)
    ... 10 more
Sep 11, 2013 9:09:30 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Sep 11, 2013 9:09:30 PM hudson.WebAppMain$3 run
SEVERE: Failed to initialize Jenkins
java.lang.InterruptedException
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:502)
    at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:244)
    at jenkins.InitReactorRunner.run(InitReactorRunner.java:43)
    at jenkins.model.Jenkins.executeReactor(Jenkins.java:906)
    at jenkins.model.Jenkins.<init>(Jenkins.java:806)
    at hudson.model.Hudson.<init>(Hudson.java:81)
    at hudson.model.Hudson.<init>(Hudson.java:77)
    at hudson.WebAppMain$3.run(WebAppMain.java:221)
Exception in thread "pool-2-thread-1" java.lang.NullPointerException
    at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:191)
    at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:679)

我试图运行sudo netstat -lp,但没有看到任何端口信息(看起来不像任何应用程序在端口80上运行)。我也尝试过使用port = 88,但结果相同。

有什么建议吗?

2 个答案:

答案 0 :(得分:5)

我遇到同样的问题,我发现如果没有root权限,你就无法收听1024以下的端口。

我们可以做几件事,但我认为最安全的是:

  • 使用 iptables
  • 将端口80重定向到8080
  

#iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

除此之外,您可以通过 chown chmod 以root身份运行jenkins,但我认为这可能很危险。

其他可能性包括在这里:

https://serverfault.com/questions/112795/how-can-i-run-a-server-on-linux-on-port-80-as-a-normal-user

答案 1 :(得分:0)

确保使用

在端口80上运行apache或其他东西
netstat -utanp | grep 80

tcp 0 0 ::: 80 ::: * LISTEN 1428 / httpd

如果在80上运行任何其他内容,请确保在80上启动Jenkins之前停止它