Where should I install my app on Linux?
We have some data import tools we've written in-house and I need to set them up on a new Linux box.
These are written in both Java and .NET (running on Mono) and they comprise binaries, config files, resources/assets like images and templates. They also write logs and look to some special folders for the data to import.
I'm new to Linux. At the moment, they're in a folder like /data/importer.java/
and /data/importManager.net/
with these folders containing everything they need to run.
But I see /data/
is a non-standard folder. So I wanted to know if there's a proper place to set them up, however it seems the on Linux, there's many, many folders each for a specific purpose and for read-only/read-write data.
Its almost as if I need to split my apps over a bunch of folders to do it properly, and some folder names, like bin
sound right but then what do I with non-binary/compiled files?
Aside from the binaries, the config and everything else is often modified by humans.
Something like (just focusing on the Java part for now):
-
/opt/importer.java/
for the binaries, config and resources -
/var/importer.java/data-in/
for dropping in data to import -
/var/importer.java/logs
for the logs written
Or maybe I should use the /srv/
folder? Or perhaps /usr/bin/
. Maybe logs should be written to the /home/
folder of the running user?
It's all so complicated. Whenever I read any Linux documentation I regret it. Should I just copy it all over from the other machine as-is and forget I ever tried?
Thanks
Luke
This is a question with no right answer and an intriguing bit of Unix history.
The rule we followed at my prior employer was that non-out-of-the-box software was installed in /opt/PackageName-VersionNumber
and there was a symbolic link from /opt/PackageName-VersionNumber
to /opt/PackageName
.
Configs go in /opt/PackageName/etc
Logs go in /opt/PackageName/logs
Binaries go in /opt/PackageName/bin
Data goes in /opt/PackageName/data
For apps that were to be distributed outside of our shop we wrote them to be relocatable by the package manager. This was a rare occurrence, and not "fun".
As far as I'm aware native linux applications are written to have their binaries in [/usr]/bin
, logs in /var
, config in /etc
, and so on. Non native applications or combinations of packages (such as lampp/xampp for example) that are meant to be used systemwide, on the other hand are by default installed in /opt
, with the configuration usually also residing in that folder. If the software is meant to run per user a folder inside their home directory is customary.