0

I guess that I should set a noob question alert on top. I am trying to deploy two Django projects locally with Apache and SQLite using mod_wsgi. Everything works fine, but I cannot figure out how to properly configure the permissions to my folders locally. Most of the relevant tutorials or posts treat the issue insufficiently or are quite difficult for me to understand. I have to say that I am using ubuntu 18.04.

My current permissions are set by

     chmod -R 755 /var/www/env1 

which is the parent directory of the project and also contains my virtual environment (using VirtualEnv). However, I understand that this is not the way to go, because I can directly download my .py files from the browser. This is the result of 'ls -la' inside the env1 folder.

drwxr-sr-x+ 10 www-data www-data 4096 Φεβ   5 21:10 .
drwxrwsr-x+  3 www-data www-data 4096 Φεβ   1 12:39 ..
drwxr-sr-x+  9 www-data www-data 4096 Ιαν  26 00:05 astronomy
drwxr-sr-x+  3 www-data www-data 4096 Φεβ   1 13:43 bin
drwxr-sr-x+  9 www-data www-data 4096 Ιαν  26 00:05 gastronomy
drwxr-sr-x+  2 www-data www-data 4096 Ιαν  25 16:46 include
drwxr-sr-x+  3 www-data www-data 4096 Ιαν  25 16:46 lib
drwxr-sr-x+  2 www-data www-data 4096 Φεβ   1 12:33 media

"astronomy" and "gastronomy" are my two project folders. Is there a way that the apache server will run locally but there will be accessible only by root users? My projects include a media folder where users are supposed to be able to upload image files, which I think is an extra issue concerning permissions.

I would really appreciate any advice or solution to understand what is the way to go. Thank you very much in advance.

Nikos T
  • 45
  • 8
  • Please understand the usage of 755 file permission. Only file owner can read, write and execute it. Other users only read and execute. https://stackoverflow.com/questions/18932536/ftp-rights-755-vs-777 – Abijith Mg Feb 06 '19 at 08:13
  • Thanks, but I do not want users to be able to read and execute all the files. Which ones are necessary? If possible I would like the current local user to be unable to browse the files .py even locally. Any ideas? – Nikos T Feb 06 '19 at 08:46

1 Answers1

0

The most important thing I had to do was to remove the "DocumentRoot" tag from my apache .conf file. What is more I have set 755 for the folder /var/www recursively and then 700 for the folders under env1 except for the db files where I have set 664. They are all owned by www-data:www-data. It works this way. If you have any suggestions I would love any insights!

Nikos T
  • 45
  • 8