Home directories on Linux distributions are often not accessible to other users. So changing permissions of directories/files under the home directory doesn't help since can't see into the actual home directory. You preferably should not stick your project code under a user home directory.
That said, one way around it is to set user/group on WSGIDaemonProcess to owner of the home directory, although that is not generally recommended as then your code runs as you and not a user with more restricted access. Anyway, you do seem to have that, so is a bit strange why that isn't working. One thing to try in order to work out whether your application is in fact running in daemon mode and somehow Apache configuration is not broken is: https://modwsgi.readthedocs.io/en/master/user-guides/checking-your-installation.html#embedded-or-daemon-mode The only other thing can think of is you have AppArmor on Ubuntu enabled and configured in a way that prevents access to directories/files in that location by Apache httpd process. This happens quite a bit with SELinux on Red Hat type operating systems, but never run into anyone who actually bothers to run AppArmor. BTW, to initialise virtual environments, it is better to avoid activate_this.py if can. See: https://modwsgi.readthedocs.io/en/master/user-guides/virtual-environments.html for recommended ways. Graham > On 16 Apr 2023, at 10:08 pm, Harald Fontius <[email protected]> wrote: > > I am trying to run a PYTHON FLASK application created in MS Visual Studio and > exported it to a directory call “conjugationgame”. > > In the VISUAL STUDIO environment it runs without problems. Now I want to > install it on a LINUX Server hosted by IONOS. > > UBUNTU 22.04.2 LTS (GNU/Linux 5.15.0-69-generic x86_64) is installed. > Apache2 is installed and shows this status: > > apache2.service - The Apache HTTP Server > Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor > preset: enabled) > Active: active (running) since Wed 2023-04-12 15:58:48 UTC; 1 day 23h ago > Docs: https://httpd.apache.org/docs/2.4/ > Main PID: 15997 (apache2) > Tasks: 71 (limit: 2193) > Memory: 30.1M > CPU: 55.237s > CGroup: /system.slice/apache2.service > ├─15997 /usr/sbin/apache2 -k start > ├─75728 /usr/sbin/apache2 -k start > ├─75729 /usr/sbin/apache2 -k start > ├─75730 /usr/sbin/apache2 -k start > └─75731 /usr/sbin/apache2 -k start > > I tried to install a mod_wsgi virtual environment following @Luke Peter’s > very good video tutorial (183) How to Deploy a Flask App to Linux (Apache and > WSGI) - YouTube <https://www.youtube.com/watch?v=w0QDAg85Oow> > In installed the application like this: > > <server_installation.png> > > > I run pipenv install according to this answer to a problem with > mutablemapping python - AttributeError: module 'collections' has no attribute > 'MutableMapping' - Stack Overflow > <https://stackoverflow.com/questions/70943244/attributeerror-module-collections-has-no-attribute-mutablemapping> > <install pipenv.png> > > Although I got an error running pipenv install after changing the directory > to var/www/conjugationgame.de/conjugationgame/: > > > <Permission_error_pipenv install.png> > > Hard to read: > > PermissionError: [Errno 13] Permission denied > ‘var/www/conjugationgame.de/conjugationgame/._atomic-writelcmrxftk’ (might be > the problem but I couldn’t find anything to solve it) > > pipenv –venv gives the link to the virtual environment: > > > <error_venv.png> > > With this link I created the wsgi file like this: > > > <wsgi.png> > > and the config file like this > > > <config.png> > > Checked the syntax of the config and restarted apache2. > > > <restart config.png> > > When calling https://conjugationgame.de <https://conjugationgame.de/> I get > this error: > > [Fri Apr 14 15:18:59.616298 2023] [wsgi:error] [pid 75730:tid > 139907032913472] [client 91.23.91.105:56927] mod_wsgi (pid=75730): Failed to > exec Python script file '/var/www/conjugationgame.de/__init__.wsgi'., > referer: https://conjugationgame.de/ > > [Fri Apr 14 15:18:59.616378 2023] [wsgi:error] [pid 75730:tid > 139907032913472] [client 91.23.91.105:56927] mod_wsgi (pid=75730): Exception > occurred processing WSGI script '/var/www/conjugationgame.de/__init__.wsgi'., > referer: https://conjugationgame.de/ > > [Fri Apr 14 15:18:59.616487 2023] [wsgi:error] [pid 75730:tid > 139907032913472] [client 91.23.91.105:56927] Traceback (most recent call > last):, referer: https://conjugationgame.de/ > > [Fri Apr 14 15:18:59.616514 2023] [wsgi:error] [pid 75730:tid > 139907032913472] [client 91.23.91.105:56927] File > "/var/www/conjugationgame.de/__init__.wsgi", line 4, in <module>, referer: > https://conjugationgame.de/ > > [Fri Apr 14 15:18:59.616520 2023] [wsgi:error] [pid 75730:tid > 139907032913472] [client 91.23.91.105:56927] with open(activate_this) as > file_:, referer: https://conjugationgame.de/ > > [Fri Apr 14 15:18:59.616569 2023] [wsgi:error] [pid 75730:tid > 139907032913472] [client 91.23.91.105:56927] PermissionError: [Errno 13] > Permission denied: > '/home/hfwds/.local/share/virtualenvs/conjugationgame-4RgIZZXj/bin/activate_this.py', > referer: https://conjugationgame.de/ > > The activate file looks like this: > > > > > I tried whatever I could find – without success. Can anybody help? > > I also tried user www-data and group www-data in the config file – same > problem. I solved the problem before following the answer in this question: > > python - Apache/Django/mod_wsgi - [Errno 13] Permission denied: - Stack > Overflow > <https://stackoverflow.com/questions/53857711/apache-django-mod-wsgi-errno-13-permission-denied> > <activatefile.png> > > but I had to reinstall the application again and now the error is permanent. > > > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/modwsgi/af11814c-bee5-49ed-9af2-1d8a6fb8c438n%40googlegroups.com > > <https://groups.google.com/d/msgid/modwsgi/af11814c-bee5-49ed-9af2-1d8a6fb8c438n%40googlegroups.com?utm_medium=email&utm_source=footer>. > <config.png><server_installation.png><restart > config.png><error_venv.png><wsgi.png><activatefile.png><Permission_error_pipenv > install.png><install pipenv.png> -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/8110DBE7-DA89-49F9-AA53-9EADAE7B9846%40gmail.com.
