F
F
FlensT2021-08-28 00:47:18
Python
FlensT, 2021-08-28 00:47:18

PermissionError: [Errno 13] Apache python, how to fix?

I know, there have already been many questions about this error, but I did not find a solution to my problem.

def log_write(text: str) -> None:
    with open("logging.log", "a") as log:
        log.write(str(text))

When using this code, an error occurs
[wsgi:error] PermissionError: [Errno 13] Permission denied: 'logging.log'

This file must be created in the root directory of the project.
Envars

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data


Access level and owner

drwxrwxrwx 3 www-data www-data 4096 Aug 27 23:56 .
drwxrwxrwx 3 www-data www-data 4096 Aug 27 19:31 ..
-rwxrwxrwx 1 www-data www-data 2094 Aug 27 21:17 __init__.py


Directory access level

drwxrwxrwx 3 www-data www-data 4096 Aug 27 19:31 .
drwxrwxrwx 4 www-data www-data 4096 Aug 27 19:23 ..
drwxrwxrwx 3 www-data www-data 4096 Aug 27 23:56 webApp
-rwxrwxrwx 1 www-data www-data  198 Aug 27 15:45 webapp.wsgi


webapp.wsgi

#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/webApp/")

from webApp import app as application
application.secret_key = 'key'


webApp.conf

<VirtualHost *:80>
    ServerName 185.251.91.76
    ServerAdmin [email protected]
    WSGIScriptAlias / /var/www/webApp/webapp.wsgi
    <Directory /var/www/webApp/webApp/>
      Order allow,deny
      Allow from all
    </Directory>
    Alias /static /var/www/webApp/webApp/static
    <Directory /var/www/webApp/webApp/static/>
      Order allow,deny
      Allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


I would be sooo grateful for any help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FlensT, 2021-08-28
@FlensT

Found a solution to my problem, started using nginx and gunicorn3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question