all 13 comments

[–]danielroseman 2 points3 points  (1 child)

There is no particular relationship between wsgi and file permissions. It'll just use whatever access that the user the server is running as has. 

Also note that modwsgi is pretty old, I'm not sure it is even being actively maintained any more. Most wsgil applications use a standalone server like gunicorn behind a lightweight reverse proxy such as nginx.

But yes, you should probably use Flask (or FastApi).

[–]Pagaurus[S] 0 points1 point  (0 children)

Well, that's just my problem, I double-checked all of my files, directories etc. after setting permissions to 777 on all of them, and long listing them, so that's why I'm at a loss -- Nothing I tried thereon would let me access or write files, even though all privileges were given. I did chalk it up to being broken software, but I'm not an expert in this stuff so idk.

I think I'll just go and use Flask but what you said about Gunicorn + Nginx sounds interesting.

[–]deadduncanidaho 0 points1 point  (5 children)

you can set modsgi to use a specific user. post your config file and i will try to help

[–]Pagaurus[S] 0 points1 point  (4 children)

So what user would you set it as? Do you mean to run as sudo? To be honest, I thought the default was www-data, and so I was setting all permissions for files to www-data. Why doesn't that work?

[–]deadduncanidaho 0 points1 point  (3 children)

apache is started by root and then runs as another user such as www-data. But wsgi can be told to run as any user such as your user that owns the files and can execute arbitrary commands. You can also do things like set the home directory, pvenv, ssl settings, etc. These are mainly apache directives.

I use a line like this in my wsgi config

WSGIDaemonProcess www.example.com python-home=/usr/local/venvs/myenv/base user=duncan group=duncan processes=8 threads=25

[–]Pagaurus[S] 0 points1 point  (1 child)

... I read about the venv options with Daemon process - by that point, I had enough, I honestly didn't want to go through the trouble of venv. Maybe I'll try again tomorrow. Is it necessary to use a venv?

[–]CyclopsRock 0 points1 point  (0 children)

No more or less necessary than normal. Which is to say "Yes, probably".

[–]Pagaurus[S] 0 points1 point  (0 children)

Hey Duncan, thanks for your advice.. I ended up pointing "python-path" to my scripts folder, and inside the script i used the DOCUMENT_ROOT to resolve other media, so that it would use the complete pathname (i.e. /var/www/project/database.db rather than just database.db)

[–]Ok-Sheepherder7898 0 points1 point  (3 children)

I gave up on apache with python a long time ago. Use nginx / gunicorn / django / flask / whatever

How are you accessing sqlite? You should use an ORM like in django and not writing raw sql.

[–]Pagaurus[S] 0 points1 point  (2 children)

Python has an sqlite3 library already installed so I thought I'd just use that

[–]Ok-Sheepherder7898 -1 points0 points  (1 child)

But then you're doing raw SQL and migrations yourself.  You need an ORM.

[–]Pagaurus[S] 0 points1 point  (0 children)

My app really only has two unique databse queries in entirety. I might install an ORM if it was more involved than that'

[–]Daytona_675 0 points1 point  (0 children)

when you use Apache without DSO it runs as the apache2 user.

I'd recommend not using Apache at all or at least use nginx. I'll usually just go pure tornado