Linux Tomcat 80端口 Port 80 required by Tomcat v8.5 Server at localhost is already in use.

Port 80 required by Tomcat v8.5 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).

因为装上了ubuntu,就在eclipse上设置tomcat端口为80,但是就显示说已被占用,不过我电脑才刚装上ubuntu,正常应该是没有其他程序被占用,然后在stackoverflow上发现的一个解答就是说linux不开放1024以下的端口给非root用户。

上网找了好多解答,我感觉还是用nginx比较靠谱,毕竟以后应该会用nginx比较多,所以我就用nginx解决了。

利用nginx把80端口的转发到8080(我在tomcat上设置的1024以上的端口)。

nginx在ubuntu上安装的简单方法,也可以用其他方法安装,随习惯

sudo apt-get install nginx

我的nginx的配置文件在/etc/nginx/nginx.conf,因为配置文件默认include了/etc/nginx/sites-available/default,这个default就是初始的nginx配置文件,里面设置了当前nginx的默认端口,也就是80,当然也可以修改为其他的。

我就在default文件里的server里,修改了location为

        location / {
 44                 # First attempt to serve request as file, then
 45                 # as directory, then fall back to displaying a 404.
 46                 # try_files $uri $uri/ =404;
 47                 proxy_pass http://localhost:8080;
 49                 index index;
 50                 root /;
 51         }

然后就保存,在命令行里输入sudo nginx -s reload

没有显示错误就代表对了,然后我就启动tomcat,在地址栏输入了localhost,成功跳转了tomcat的项目里了。

转载于:https://www.cnblogs.com/sevenun/p/6427484.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值