Setup:
Ubuntu 20, Tomcat 9, upload dir:
/myapp/upload
(myapp & upload dir already owner by user tomcat and permission 775). Problem:
application on tomcat still can't write into upload dir (this setup already works on Centos 7 & 8).
Solution:
source: https://stackoverflow.com/questions/56827735/how-to-allow-tomcat-war-app-to-write-in-folder#56835997
edit file
/etc/systemd/system/multi-user.target.wants/tomcat9.service
(don't forget to use sudo
) and add the following lines under [Service]
section:ReadWritePaths=/path/to/the/directory/
save the file then reload service:
systemctl daemon-reload
systemctl restart tomcat9
Done, now the application on tomcat has write access into upload dir.