31

I'm running 4 separate Node.js apps on a Linux server with different ports and a proxy in front.

As I'm (right now) the only user in the server, it doesn't matter where I place the apps and how to run them. Currently my apps stay under my home directory (~/app1/, ~/app2/, etc.).

So my question is: where should I place the apps so that they can be shared between multiple users? Is there a standard place similar to /var/www?

4
  • 3
    possible duplicate of How to deploy node.js? Commented May 29, 2012 at 13:10
  • 1
    True, that question solves my problem partly. I will rephrase the question. Commented May 29, 2012 at 13:13
  • 1
    What do you mean by "shared between multiple users"? Do you plan to run each app more than once at the same time? Commented May 29, 2012 at 13:19
  • 1
    Good question. Like with Apache you have www-data and /var/www. Is there some common, similar practise for node.js? Commented May 29, 2012 at 13:31

4 Answers 4

16

I use https://github.com/visionmedia/deploy to deploy my apps. It will create a /var/www/productname directory. Inside that directory you have source, current and shared. The shared directory has the log and pid files.

I found that a good directory structure so that's what I am using for all my projects.

Sign up to request clarification or add additional context in comments.

2 Comments

Deploy seems really nice, thanks! I will be trying that out soon to see it myself and will get back to you.
I think /var/nodejs is better / safer since /var/www was used by web servers like Apache in the past (instead of the new standard /var/www/html). Using /var/www for Node.js apps could add a risk of having all your server-side source code visible to unauthorized users.
13

I run Apache in addition to Node.js on the same server, so I don't really like having applications for Apache and Node.js in the same directory. My Apache hosted applications go in the traditional /var/www/ path, and I put my Node.JS applications under /var/node/. This is due to some automation I have setup in both Apache (Dynamic Virtual Hosts) and Node.JS.

More information on my setup and automating Proxy and Apache deployment can be found here: How to use vhosts alongside node-http-proxy?

1 Comment

Very nice suggestion, thanks! I'll get back to this later after some self-experimentation.
4

If you are using AWS Elastic beans stack for Node JS application on Linux server, then it should be there in /var/app/current/ directory

Comments

4

Following the guidelines of the answer here - https://serverfault.com/a/96420 indicates that /opt/node might be a better places for this, since it'a catchall directory that's reserved for user added program files

3 Comments

Don't you mean /opt?
I think the right answer is actually /srv - unix.stackexchange.com/questions/35807/…
I feel like apps should be in /opt and files served in /srv and in the Node.js case, it's an app, not shared files. pathname.com/fhs/pub/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.