2

Let's say you are developing a web application which generates reports based on user interaction. If you wanted to store those reports (not just temporarily cache them) somewhere in the *nix filesystem, where would be the most canonical default location?

My first instinct is /var/application-name or /var/www/application-name, similar to log files, since /var is for "variable" sized content, per linux.com's description of the filesystem.

However, /srv/application-name also seems appropriate, per the very same article's example of an FTP service.

It also seems appropriate to use /usr/local/ or /usr/share/.

4
  • I would recomment not to save it on filesystem because your app won't scale. Save on filesystem only app files, ie. separate app from its data. Ideally save its data in distributed filesystem like S3 or in a DB. All this /var vs /srv location disputes are ridiculous. Especially today in time of containers. The main point of web app location should be mount options of underlying filesystem, ie. you don't want to have suid, dev option for the filesystem hosting your app files.
    – Jiri B
    Mar 26, 2021 at 14:49
  • This question is specifically for "traditional" web applications, the type that are still developed around the world. In my case, the application is already containerized; however, we have customers who insist on a systemd-compatible deployment option, as they cannot run containers in their environment because of "reasons". Plus, in the end, you're eventually going to have to store the files in a filesystem somewhere, even if you're using containers with a backing store. The question isn't "should I?" it's "If I were, where would I?".
    – b4ux1t3
    Mar 26, 2021 at 14:55
  • As most webservers have /var/www defined as root dir, you should then use it. For example on OpenBSD webservers chroot into /var/www for security reasons. But really think about moving /var/www (or any your desired location) to separate filesystem and give it secure mount options.
    – Jiri B
    Mar 26, 2021 at 14:57
  • I feel it's also worth clarifying, for these comments anyway, that I am the developer of the application looking for a sane and canonical default location. In the end, I will not be maintaining the production version of the application. This location will be configurable by the end user, both though the application and by editing the Unit file itself.
    – b4ux1t3
    Mar 26, 2021 at 14:59

1 Answer 1

0

First thing is not to put your app files into root filesystem. Then the location really is up to you. Keep the filesystem hosting your app separate from any OS files, so you can always reinstall OS while keeping your app files intact.

2
  • All of the listed locations are off of the root filesystem, and are explicitly documented as being appropriate for service and/or user (system user, not "person" user) use.
    – b4ux1t3
    Mar 26, 2021 at 14:57
  • For example a big German bank, I was doing sysadmin for, uses /app/<app>. If one knows why he does it this way, all possibilities are valid but one must know why he does it this way.
    – Jiri B
    Mar 26, 2021 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .