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

  • 相关阅读:
    docker mysql 主从配置
    在docker上安装运行mysql实例
    mongodb分片集搭建
    mongodb片健的选取及更改
    MySQL 5.7的多源复制
    percona-toolkit使用教程
    Python基础操作-集合
    nginx location 在配置中的优先级
    OpenResty知识汇集
    开源分布式日志框架
  • 原文地址:https://www.cnblogs.com/stuka/p/14661837.html
Copyright © 2011-2022 走看看