What Folder(s) Can My Tomcat Application Write To on Ubuntu Server

后端 未结 1 446
囚心锁ツ
囚心锁ツ 2021-01-05 16:40

I\'m not sure if the fact that i\'m using Ubuntu Server matters in this case. When I am trying to create folder using the File.mkdirs() method, it doesn\'t throw an exceptio

1条回答
  •  抹茶落季
    2021-01-05 17:38

    If you're using ubuntu's packaged version of tomcat, this is running under a different user account - most likely named 'tomcat'. Double check with ps aux | grep catalina - this will display the username that tomcat is running as in the first column. Exactly this user account needs to be able to create the directories/files.

    For this reason, you probably don't want to open arbitrary home directories to be world-writeable, but rather configure specific directories somewhere to be accessible by the tomcat user. Setting a 755 permission gives the owner read/write/execute permissions, while everybody else gets read/execute permission. If 'tomcat' is not the owner, it will not be able to create anything in these directories. But don't fall for the trap to chmod 777 - unless it's for a quick test.

    0 讨论(0)
提交回复
热议问题