Where should I store/run my server? /opt/?

I’ve just set up my droplet according to this MEAN.JS tutorial and configured to use a non-root user per this tutorial. The first says that if I already have an application build on the MEAN stack (I do), I should git clone it into /opt/. This of course causes fatal: could not create work tree dir 'visigraph'.: Permission denied, since I’m not running as root or sudoing.

Now of course I could just sudo it, but then I believe I would also have to run the server as root, which is obviously bad from a security standpoint. So is /opt/ just the wrong place to run my server out of? Or should I just chown the cloned project dir? What are the security implications? I’ve never dealt with setting up the permissions side of a server, and am not familiar with what each of the root dirs in Linux are intended for.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

The great part is you can really run it from wherever you like, it just depends on some tweak to configuration. You could change permissions to run it in /opt, or you could have it run from /home/user instead and change the configuration to have it recognize it is stemming from there. It all depends on how you want to do it!

Me personally, I don’t like running my node.js applications from /opt. I like running things from my user’s HOMEDIR or somewhere within /var

Hope it helps, Jason Colyer DigitalOcean Platform Support Lead