I'm running Tomcat 8 on Linux and there I have a folder
/opt/files
where tomcat and other applications should save and access files. However, I don't know how to set this up in Tomcat to make use of these files
I'm running Tomcat 8 on Linux and there I have a folder
/opt/files
where tomcat and other applications should save and access files. However, I don't know how to set this up in Tomcat to make use of these files
A. Use linux soft link is the easiest way
sudo ln -s /opt/files /var/lib/tomcat8/webapps/optfiles
You don't needed change any thing about tomcat.
B. You can also make a soft link to your webapps
fold, or even in your webapps/myapp
folder (use sudo ln -s /opt/files /var/lib/tomcat8/webapps/myapp/optfiles
), but in this situation you must change context.xml
file
<Context allowLinking="true" >
the allowLinking
link attributes make the files accessible, but not recommend for safety reason.
and
C. Depends how you install the tomcat 8, in short, find your tomcat conf
direcotry, change the server.xml like below
<Server ...>
<Engine>
...
<Service>
...
<Host name="image.hostname.com" appBase="/opt/files"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
<Host name="app.hostname.com" appBase=""
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server>
and now your can access your file through http://your.hostname.com:8080
If you use ubuntu
apt-get
install your tomcat, you can find the configuration files holds in folder /var/lib/tomcat8/conf
or /etc/tomcat8/