Where should websites be stored at? reddit / freebsd ---------------------------------------------------------------------- normalu_kaj225i · 2020-09-19 17:09 There're multiple websites, written in different languages and frameworks, on the same server. Some will work via nginx, others via apache, yet others via their own built-in web server. Where in the file system is it recommended to store them? ---------------------------------------------------------------------- oratpart · 2020-09-19 17:21 The package manager likes /usr/local/www so I often use that out of habit. Sometimes I make a top level zfs dataset for servers and a dataset for each site under that. If it fits your workflow, this sounds like a really good opportunity to use jails to help compartmentalize things. Your future self with thank you when you inevitably need to upgrade one server in a way that breaks another. ---------------------------------------------------------------------- jurrehart · 2020-09-19 17:22 Not an expert, but this seems perfect to have each one in its own jail. If I'm not mistaking that would be each jail in its own directory. But I ask the veterans and jail experts to correct me if I'm wrong or integrate this answer with needed details. ---------------------------------------------------------------------- xplosm · 2020-09-19 17:22 Apache's docs tell you were to put Apache websites, same goes for NGINX, and the rest of the apps. If you feel you need more space and are limited by constrains of the partition scheme or filesystem in general you can symlink yous resources to external media or additional disks in the same server. ---------------------------------------------------------------------- normalu_kaj225i · 2020-09-19 17:41 what then will tell me the build-in servers of each project? ---------------------------------------------------------------------- normalu_kaj225i · 2020-09-19 17:43 As for jails, how can I make that approach even more complex? ---------------------------------------------------------------------- xplosm · 2020-09-19 17:45 I don't understand your question. If you are asking where the docs for the services are, visit their websites. You can also check the man pages for the things you have installed. Nothing is FreeBSD specific for your use case. The OS is only an abstraction to manage your hardware. You can use many as long as your HW supports them. ---------------------------------------------------------------------- normalu_kaj225i · 2020-09-19 17:51 You've assumed that I'd use only standard well known web servers - Nginx and Apache and thus have misunderstood my question. Forget about these servers because I could use any other web server which has no documentation, or my own. My question: where should websites be stored at in the file system, regardless of a web server? Or where is it recommended? ---------------------------------------------------------------------- [deleted] · 2020-09-19 18:41 /var/www/html /var/www/data /var/www/$cmsname Are the usual spots . differs from rhel/debian/arch etc etc ---------------------------------------------------------------------- edthesmokebeard · 2020-09-19 19:48 I think you meant c:\\inetpub\\ ---------------------------------------------------------------------- desnudopenguino · 2020-09-19 19:49 /var/www/... As others have mentioned is usually where you stick web things for traditional servers, but they *can* be placed pretty much anywhere in the filesystem. How are you serving with all of these different services? I know you can stack some and reverse proxy and such, but it all seems like a big nightmare. Does each service attach to a specific ip, or a specific port? I'm of the opinion jails would work well with this. Then you can separate things out that way. If it is a local/dev server and you can add ips, I would give each jail a different ip to keep things separate that way. If you are using node or Ruby or python frameworks, they are usually in some directory owned by a non-root user, and the application is run by that user, then forwarded through a more popular web server. ---------------------------------------------------------------------- to_wit_to_who · 2020-09-19 20:53 As others have said, jails are likely your best answer here. I do the same and using ZFS jails have had major benefits for me (e.g. deployment, rollback, isolation, etc). Within the jail, it doesn't really matter where you put the files. I'd suggest staying away from the base system though, so either in /var or /usr/local/www. A dedicated user + home directory is also an option, depending on what else would be co-located in the jail. ---------------------------------------------------------------------- nahnah2017 · 2020-09-19 21:31 There is the usual place servers will install it in and there is the place you want to install it in. Everyone has told you where server software will typically put it and that's fine but you can put it anywhere you want. I put some of mine on /www because it suits me. ---------------------------------------------------------------------- throwaway997918 · 2020-09-19 23:24 I get a little uncomfortable just looking at that path again. Thank god it's over... ---------------------------------------------------------------------- throwaway997918 · 2020-09-19 23:26 /var/www/$domain_name ---------------------------------------------------------------------- normalu_kaj225i · 2020-09-20 07:35 /var/www/ belongs to root:root, right? And I'd have to give permissions to my "deployer" user each of my projects in /var/www/{$domain_name} ? ---------------------------------------------------------------------- normalu_kaj225i · 2020-09-20 07:36 Ok. What are the usual or recommended places in ArchLinux then? ---------------------------------------------------------------------- normalu_kaj225i · 2020-09-20 07:38 You're wrong. I'm an expert. ---------------------------------------------------------------------- throwaway997918 · 2020-09-20 09:56 Yes, and r on r+w for the user the client's webserver/webservice is running as, in eg. /var/www/{$domain_name}/public Don't let them all run as nobody:nobody granting full access to /var/www/{$domain_name} as this will give the webservers/webservice access to each others directories. The last thing to consider is using the reverse domain name eg.: /var/www/com.reddit.www for nice natural sorting of domains, but it only makes sense if you have 10-15+ domains to keep track of. ---------------------------------------------------------------------- normalu_kaj225i · 2020-09-20 11:48 Is it a correct thing to do in Linux, in general: the directories "/var" and "/var/www" are owned by root, but the nested ones - "/var/www/{my_sites}/{siteN}" - will now be owned by some other, less privilegied user? ---------------------------------------------------------------------- darkempath · 2020-09-21 07:21 >Apache's docs tell you were to put Apache websites, same goes for NGINX, Nah, then you end up with inconsistent shit everywhere, like on a linux system. Websites should go in /usr/local/www unless there's a specific reason otherwise. ---------------------------------------------------------------------- Lord_Mhoram · 2020-09-21 14:33 If I have multiple users with different web sites and they will be uploading files with something like SFTP, I will give them login accounts and put their web sites in $HOME/www/domain.com. If they're using PHP, php-fpm can run their scripts as user and chroot them so they can't see into each other's directories. If I want to let them have a choice of web servers, I will put each web server in its own jail and nullfs mount /home into each jail so that each web server can access it. Another option would be to put each user in his own jail, in which case the files could go wherever you like, like /usr/local/www. Then a reverse proxy sitting on one IP can direct requests to the correct jail on an internal IP address. Whether that makes sense probably depends on how many users you have and how many different web servers you plan to run. There is no official way to do any of this; it depends on your needs. ---------------------------------------------------------------------- normalu_kaj225i · 2020-09-21 17:16 I don't know what question you've just answered. ---------------------------------------------------------------------- vivekkhera · 2020-09-24 12:42 I put them in their own ZFS dataset under /web. For example, Jira is in the data set mounted as /web/jira in a sub directory /web/jira/8.12, based on the version number. I will have a symlink /web/jira/current point to the version running and the config files reference everything via the current link. Inside /web/jira is a file httpd.conf which has the VirtualHost container directives for Apache for this service and mostly consists of proxy config to the application server. My main httpd.conf does a wildcard Include for /web/*/httpd.conf so picks up everything I need on a restart. ---------------------------------------------------------------------- throwaway997918 · 2020-09-24 13:44 Exactly, and not the same unprivileged user. In the Linux-world the distros often use: /var/www/domain, /var/html/domain or: /opt/www/domain In the BSD world: /usr/local/www/domain It matters more that you follow the Linux distro/OS default than the actual path. I always put Nginx/Apache files under C:\inetpub\Domain on Windows, as a Windows administrator would always search there first. ---------------------------------------------------------------------- TorMazila · 2020-09-25 18:15 You should consider several things: 1. If website A gets hacked - is it OK that it may "influence" website B? If no - you should run each in the jail of its own. 2. If you run lots of sites - the approach from 1 may not be affordable. So you may need exotic things, like dklab apache with per- site chroot/chuid support (unfortunately, this is patch only exists for apache 1.x, there exist similar functionality on 2.x but it's not that good) 3. You may be better if you have some nginx or envoy in front of your multiple servers - to log things, limit load and such