我在Centos 7上安装了基于Jetty服务器的Jenkins。 在配置文件中:/ etc / sysconfig / jenkins默认端口是8080,一切都运行正常,但我需要在80端口上移动jenkins。
当我将JENKINS_PORT =“8080”更改为JENKINS_PORT =“80”时 - jenkins不再可用。防火墙我关掉了。
日志消息中的:/ var / log / jenkins / jenkins.log
Aug 17, 2017 12:07:45 PM org.eclipse.jetty.util.log.JavaUtilLog warn
WARNING: FAILED ServerConnector@4082ba93{HTTP/1.1}{0.0.0.0:80}: java.net.SocketException: Permission denied
java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:366)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at winstone.Launcher.<init>(Launcher.java:152)
at winstone.Launcher.main(Launcher.java:352)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at Main._main(Main.java:293)
at Main.main(Main.java:132)
任何人都可以帮我解决这个问题吗?
答案 0 :(得分:3)
Google引导我https://confluence.atlassian.com/confkb/permission-denied-error-when-binding-a-port-290750651.html
1024以下的端口称为特权端口,在Linux(以及大多数UNIX风格和类UNIX系统)中,任何非root用户都不允许打开它们。
因此,当我以JENKINS_USER =“jenkins”运行启动脚本时,出现了Permission denied错误。
答案 1 :(得分:0)
我为这个问题奋斗了几个小时。我要做的最终是在Ubuntu上,将JENKINS_USER
变量值从$ NAME更改为/etc/default/jenkins
的根目录。然后,我通过运行以下命令重新加载了守护进程。
$ systemctl daemon-reload
最后,我以root身份重新启动了jenkins。
$ service jenkins restart
答案 2 :(得分:0)
@Nimda回答https://stackoverflow.com/a/45754065/3471694
我在
SEVERE: Container startup failed
java.io.IOException: Failed to start Jetty
at winstone.Launcher.<init>(Launcher.java:186)
at winstone.Launcher.main(Launcher.java:354)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at Main._main(Main.java:344)
at Main.main(Main.java:160)
Caused by: java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:339)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:307)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:395)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at winstone.Launcher.<init>(Launcher.java:184)
... 7 more
解决方案:编辑文件/ etc / sysconfig / jenkins或任何jenkins的配置文件
-将#JENKINS_USER =“ jenkins”更改为可以以root用户身份运行的任何用户
例如:JENKINS_USER =“ root”
希望有帮助
答案 3 :(得分:0)
80非root用户不能访问,而jenkins是非root用户。我更改了端口号,然后为我工作了。
答案 4 :(得分:-1)
你能试试这个Centos7防火墙设置吗?
不需要关闭防火墙。
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-all
然后开始詹金斯。