0

I'm new to hosting my own webserver. I was curious and this may be an stupid question, but what location is practical and secure to for hosting on the web? /home/user/ or /var/www/html?? Because packages I download need to be in the same location as the my forum, blog. Whats the best location to use? Because I'm not sure if npm package can be in www/html. Please advise me on this.

Using nginx 1.6

0

I suggest putting it at a place of your convenience, probably create anther directory in your root.

The only thing to be aware here are the filesystem permissions you will set for your website's directory.

  • I disabled root and only use user account. – Usernamehere Feb 3 '16 at 22:30
  • I'm referencing the root directory of your filesystem, which you can go to by typing: cd / It's great if you disabled the root user by default, but you can still make root commands with sudo [command] I suggest reading about the structure of a *nix filesystem here - cyberciti.biz/tips/… – LosTre Feb 6 '16 at 10:35
0

TL;DR

I use /srv for web server content and /var for general content.

Longer explanation

To me, /var implies generated content. I'll use in /var for text processing (before importing to a database or something), but I always use /srv for server-side components (i.e.. py,php). In 20 years, I've never used /var/www/html. Aside from being too hidden for my tastes, it's dishonest as I don't serve HTML files; I serve generated content that may or may not be related to HTML. That's not to mention that some packages will simply enact eminent domain on it. Just avoid it.

Above all: do NOT create another directory in your /. That is an absolutely insane idea. Never do this. / is sacred. Tread lightly for you are on holy ground.

Having said that, you mentioned packages; this is usually what /usr/local is for. You might find that stuff just gets installed there anyway. /usr/share is anohter popular place. You might not have a choice in the matter; check to see if the packages already have a predefined location.

Whatever you do, just make sure you set ownership right (example path; use /var if you want-- you have to make your own decisions):

sudo chown -R www-data:www-data /srv*

I'd suggest you look at something official: http://www.pathname.com/fhs/pub/fhs-2.3.html

Don't trust people who say "this is for this one thing and that is for that one thing" without using at least 3 paragraphs to explain it. The lines are blurred. When you read about /tmp and /var you may initially feel they are the same thing, but you'll quickly learn the real differences (especially if you're on a system that doesn't persist /tmp at all).

The FHS is very much like language where words don't so much have definitions (as one learns in primary school), but have a semantic range of meaning (as one learns in grad school). It takes time to get the feel for it. You'll have an smoother time transitioning between Debian and RedHat-based systems if you keep the semantic range in mind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.