LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Which folders are suitable for storing / serving production frontend and backend code? (https://www.linuxquestions.org/questions/linux-newbie-8/which-folders-are-suitable-for-storing-serving-production-frontend-and-backend-code-4175733285/)

charliegreen 01-28-2024 12:34 PM

Which folders are suitable for storing / serving production frontend and backend code?
 
I have an Amazon Linux (EC2) instance that I'm using to host a web application that consists of React front end and a python Flask api backend. I'm using Nginx to serve the application. So far I have placed everything as follows during development,

- python virtual env is stored in /home/ec2-user/pyenv/ folder

- frontend is located in nginx folder /usr/share/nginx/react-frontend

- backend is located under same nginx folder /usr/share/nginx/flaskapi

- my sqlite db, log file, and temp working directory are in same location as backend code /usr/share/nginx/flaskapi/log.db, /usr/share/nginx/flaskapi/log.txt, /usr/share/nginx/flaskapi/tmp/

I need to create a new user to run everything with permission only to the files/folders needed, so I wanted to know is it ok to leave everything where it is on the server or should I relocate somewhere more appropriate?

computersavvy 01-28-2024 09:51 PM

Most web based files seem to be placed under /var/www/html with the apps under /var/www/cgi-bin when using the apache web server. I suspect that nginx should probably be done similarly since selinux may also come into play for security of both the app and the data.

I think the log files should be in the standard location -- under /var/log and not isolated with the app itself.
The python venv could also be under the cgi-bin directory since that is designed for the executables being used by the web apps.

The tree under /usr/share is a config tree and not really intended as an app tree.
The /var tree is intended to allow various items to add and remove data while /usr is not. /usr should be mostly static.

charliegreen 01-29-2024 10:42 AM

Quote:

Originally Posted by computersavvy (Post 6479938)
Most web based files seem to be placed under /var/www/html with the apps under /var/www/cgi-bin when using the apache web server. I suspect that nginx should probably be done similarly since selinux may also come into play for security of both the app and the data.

I think the log files should be in the standard location -- under /var/log and not isolated with the app itself.
The python venv could also be under the cgi-bin directory since that is designed for the executables being used by the web apps.

The tree under /usr/share is a config tree and not really intended as an app tree.
The /var tree is intended to allow various items to add and remove data while /usr is not. /usr should be mostly static.

I don't seem to have those locations (var/www/html and var/www/cgi-bin) on my server. I suppose those under /var/www/ are apache specific? I have the /var/log/ folder though so I'll move my log files into there.

It seems that /usr/share/nginx/html/ is the default location that nginx looks for the front end files when you first install it and the 'welcome to nginx' html page is located in there. But I 'll move my app files to the /var folder instead.

boughtonp 01-29-2024 11:15 AM


 
Yes, move them.

For things like this there can be multiple opinions and no single right answer, but there are wrong answers - and those files in /usr/share seems like one to me.

For a formal opinion, read through the FHS, though keep in mind compliance with it is a convention not a strict requirement.

Then put files wherever your team - current and future - find most logical and easy to work with. (And if that involves creating new directories, do it.)

Whether they end up in /var/www/html or /usr/local/nginx/html or /opt/mywebapp or /home/webstuff or something else - ultimately there are pros and cons to each of those, what matters the most is making sense to the sysadmins and developers who are dealing with it.

(And if the paths used do vary from what other people using the same software use, a note of explanation in the readme and/or setup documentation obviously makes sense.)



All times are GMT -5. The time now is 04:29 PM.