zoukankan      html  css  js  c++  java
  • tomcat非root用户启动报错

    # root用户启动Tomcat时存在安全隐患,用非root用户启动时报错java.net.BindException(一般80/443),一般是因为1024以下端口非root无权限。

    # 解决方法:设置端口转发。

    # 需要使用到的命令如下:

      #1.启动防火墙               systemctl start[status] firewalld.service
      #2.关闭防火墙               systemctl stop firewalld.service
      #3.设置开机启动              systemctl enable firewalld.service
      #4.停止并禁用开机启动           systemctl disable firewalld.service
      #5.重启防火墙(执行7~12需要执行该命令)    firewall-cmd--reload
      #6.查看已开放的端口(默认不开放任何端口)      firewall-cmd --list-all
      #7.启用IP伪装                     firewall-cmd --add-masquerade --permanent
      #8.禁用IP伪装                                                    firewall-cmd --remove-masquerade --permanent
      #9.增加转发规则                                                firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080 --permanent
      #10.删除转发规则                                              firewall-cmd --remove-forward-port=port=80:proto=tcp:toport=8080 --permanent
      #11.开放端口                                                     firewall-cmd --add-port=80/tcp --permanent
      #12.移除端口                                                     firewall-cmd --remove-port=80/tcp --permanent

    # 思路如下:

    1.修改conf/server.xml中的配置,将1024以下的端口改成1024以上,这里以80端口为例

      

     2.启动防火墙:systemctl start firewalld.service。(注意:关机后防火墙不会自动开启,策略失效,如需要请设置防火墙开机自启)

     3.启用IP伪装:firewall-cmd --add-masquerade --permanent(实测此步骤非必须,博主误解了该命令

     4.开启需要使用的端口:

      firewall-cmd --add-port=80/tcp --permanent
      firewall-cmd --add-port=22/tcp --permanent
      firewall-cmd --add-port=443/tcp --permanent
      firewall-cmd --add-port=3306/tcp --permanent

     5.配置转发规则:(说明:应用需要使用的是80和443,server.xml里配置的是8080和8443,所以规则如下,即80的访问转发到8080,所以第4步无需开放8080端口) 

      firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080 --permanent 
      firewall-cmd --add-forward-port=port=443:proto=tcp:toport=8443 --permanent

     6.加载配置,使之生效:firewall-cmd --reload

     7.查看配置的规则:firewall-cmd --list-all

     8.使用非root用户启动Tomcat。

    作者:stuka

    个性签名:教育的目的是为了获得与个人兴趣爱好相适应并得到国家和社会认可的能力

    如有帮助请点击右下“推荐”

    wechat alipay

  • 相关阅读:
    POJ 3041 Asteroids 最小点覆盖 == 二分图的最大匹配
    POJ 3083 Children of the Candy Corn bfs和dfs
    POJ 2049 Finding Nemo bfs 建图很难。。
    POJ 2513 Colored Sticks 字典树、并查集、欧拉通路
    POJ 1013 Counterfeit Dollar 集合上的位运算
    POJ 2965 The Pilots Brothers' refrigerator 位运算枚举
    无聊拿socket写的100以内的加法考试。。。
    POJ 1753 Flip Game
    初学socket,c语言写的简单局域网聊天
    汇编语言 复习 第十一章 标志寄存器
  • 原文地址:https://www.cnblogs.com/stuka/p/14661837.html
Copyright © 2011-2022 走看看