LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-28-2024, 12:34 PM   #1
charliegreen
LQ Newbie
 
Registered: Jan 2024
Posts: 4

Rep: Reputation: 0
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?
 
Old 01-28-2024, 09:51 PM   #2
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
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.

Last edited by computersavvy; 01-28-2024 at 10:06 PM.
 
Old 01-29-2024, 10:42 AM   #3
charliegreen
LQ Newbie
 
Registered: Jan 2024
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by computersavvy View Post
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.

Last edited by charliegreen; 01-29-2024 at 10:44 AM.
 
Old 01-29-2024, 11:15 AM   #4
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,601

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546

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.)


Last edited by boughtonp; 01-29-2024 at 11:16 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Which External Hard disk 1 TB suitable to transfer or copy file from Linux Fedora 8 OS ? The following External Hard Disk wil be suitable RAJIB BNG Linux - Hardware 2 09-23-2017 02:12 AM
LXer: A simple, scalable solution for storing and serving build artifacts LXer Syndicated Linux News 0 08-27-2015 03:00 PM
minimum configration needed for linux machine serving as production app server fachhoch@gmail.com Linux - Newbie 2 05-11-2012 12:19 PM
Turn KnoppMyth backend/frontend into backend only nebbus Linux - General 0 09-09-2007 01:57 AM
Keeping a development serving in sync with a production server. Passive Linux - Software 2 01-06-2004 11:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration