1

I have tried everything out there to try and get rid of this error including this stack post

Tried setting media root as mentioned elsewhere.

This post seems to have outlined the problem but no solution was given.

Any help would be greatly appreciated. TIA :)

     [Errno 13] Permission denied: '/var/www/.config' 
        Request Method: POST
        -Django Version:    1.11.3 Exception Type:  PermissionError Exception Value:     
[Errno 13] Permission denied: '/var/www/.config' Exception 
        Location:   /home/--/myproject/myprojectenv/lib/python3.5/os.py in
           makedirs, line 241 Python
           Executable:  /home/--/myproject/myprojectenv/bin/python 
        Python Version: 3.5.2 Python Path:   ['/home/--/myproject', 
           '/home/--/myproject/myprojectenv/lib/python35.zip', 
           '/home/--/myproject/myprojectenv/lib/python3.5', 
           '/home/--/myproject/myprojectenv/lib/python3.5/plat-x86_64-linux-gnu',
           '/home/--/myproject/myprojectenv/lib/python3.5/lib-dynload', 
           '/usr/lib/python3.5',  '/usr/lib/python3.5/plat-x86_64-linux-gnu', 
           '/home/--/myproject/myprojectenv/lib/python3.5/site-packages'] Server
           time:    Sat, 12 Aug 2017 12:08:02 +0000

Error details from the server. Seems to be emanating from biopython trying to write to var/www/ folder

            raise exception ...
▼ Local vars
Variable    Value
__module__  
'Bio.Entrez.Parser'
__qualname__    
'DataHandler'
local_dtd_dir   
'/var/www/.config/biopython/Bio/Entrez/DTDs'
local_xsd_dir   
'/var/www/.config/biopython/Bio/Entrez/XSDs'
/home/---/myproject/myprojectenv/lib/python3.5/site-packages/Bio/Entrez/Parser.py in DataHandler
        os.makedirs(local_dtd_dir)  # use exist_ok=True on Python >= 3.2 ...
▼ Local vars
Variable    Value
__module__  
'Bio.Entrez.Parser'
__qualname__    
'DataHandler'
local_dtd_dir   
'/var/www/.config/biopython/Bio/Entrez/DTDs'
local_xsd_dir   
'/var/www/.config/biopython/Bio/Entrez/XSDs'
/home/---/myproject/myprojectenv/lib/python3.5/os.py in makedirs
            makedirs(head, mode, exist_ok) ...
▼ Local vars
Variable    Value
exist_ok    
False
head    
'/var/www/.config/biopython/Bio/Entrez'
mode    
511
name    
'/var/www/.config/biopython/Bio/Entrez/DTDs'
tail    
'DTDs'
/home/---/myproject/myprojectenv/lib/python3.5/os.py in makedirs
            makedirs(head, mode, exist_ok) ...
▼ Local vars
Variable    Value
exist_ok    
False
head    
'/var/www/.config/biopython/Bio'
mode    
511
name    
'/var/www/.config/biopython/Bio/Entrez'
tail    
'Entrez'
/home/---/myproject/myprojectenv/lib/python3.5/os.py in makedirs
            makedirs(head, mode, exist_ok) ...
▼ Local vars
Variable    Value
exist_ok    
False
head    
'/var/www/.config/biopython'
mode    
511
name    
'/var/www/.config/biopython/Bio'
tail    
'Bio'
/home/---/myproject/myprojectenv/lib/python3.5/os.py in makedirs
            makedirs(head, mode, exist_ok) ...
▼ Local vars
Variable    Value
exist_ok    
False
head    
'/var/www/.config'
mode    
511
name    
'/var/www/.config/biopython'
tail    
'biopython'
/home/---/myproject/myprojectenv/lib/python3.5/os.py in makedirs
        mkdir(name, mode) ...
▼ Local vars
Variable    Value
exist_ok    
False
head    
'/var/www'
mode    
511
name    
'/var/www/.config'
tail    
'.config'

This is how wsgi config looks

Alias /static /home/usr/myproject/static
<Directory /home/usr/myproject/static>
    Require all granted
</Directory>

<Directory /home/usr/myproject/myproject>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess myproject python-path=/home/usr/myproject python-home=/home/usr/myproject/myprojectenv
WSGIProcessGroup myproject
WSGIScriptAlias / /home/usr/myproject/myproject/wsgi.py

  • 1
    run your server as root – Arpit Solanki Aug 12 '17 at 12:33
  • You cannot run code under mod_wsgi as root and running as root is a bad idea because if someone breaks into your application code, they are then root on your system. Trying overriding ``HOME`` environment variable to be a directory which is writable as the user Apache run as. Better still, ensure you are using mod_wsgi daemon mode and run the daemon process as distinct user account you create just to run your application. – Graham Dumpleton Aug 12 '17 at 12:36
  • I followed https://stackoverflow.com/questions/21797372/django-errno-13-permission-denied-var-www-media-animals-user-uploads The GOOD solution would be: codeblock>sudo groupadd varwwwusers sudo adduser www-data varwwwusers sudo chgrp -R varwwwusers /var/www/ sudo chmod -R 760 /var/www/ Wouldn't that open up the directory for apache? – Aneesh Panoli Aug 12 '17 at 12:56
  • 1
    I solved it by changing the ownership sudo chown -R www-data:www-data /var/www/ Wondering what are the downsides, if any? @GrahamDumpleton, could you please comment? Thank you! – Aneesh Panoli Aug 13 '17 at 11:04

0 Answers0