首页 > 解决方案 > Virtualenv,WSGI 守护进程错误。权限被拒绝:mod_wsgi,uid

问题描述

我检查了一些类似的问题。ex) mod_wsgi 无法连接 WSGI 守护进程
,但至少我认为它对我的问题不起作用。
我的错误与该链接相同。

(13)Permission denied: mod_wsgi (pid=6402): Unable to connect to WSGI daemon process 'djangoServer' on '/etc/httpd/run/wsgi.6399.0.1.sock' as user with uid=99.

所以我插入socket-user=#99但它不起作用。user=#99 group=#99也未能解决。


系统是 Centos7, python2.7.5, apache2.4.6
而 Virtualenv 是 django app 3.0.3, python 3.6.8

我的 django.conf 是

# WSGISocketPrefix /var/run/wsgi

<VirtualHost *:80>
  DocumentRoot /usr/rest_auth
  ServerName djangoServer

  WSGIDaemonProcess djangoServer user=#99 group=#99 python-path=/usr/myvenv/lib/python3.6/site-packages
  WSGIProcessGroup djangoServer
  WSGIScriptAlias / /usr/rest_auth/rest_auth/wsgi.py

  <Directory "/usr/rest_auth/rest_auth">
    <Files wsgi.py>
      Require all granted
    </Files>
  </Directory>

  Alias /assets/ /usr/rest_auth/static/
  <Directory /usr/rest_auth/static>
    Allow from all
  </Directory>
</VirtualHost>

wsgi.py 是

import os, sys

from django.core.wsgi import get_wsgi_application

path= os.path.abspath(__file__+'/../..')
if path not in sys.path:
    sys.path.append(path)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rest_auth.settings")

application = get_wsgi_application()

我试图通过这个链接解决它。https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGISocketPrefix.html

第一步,我在<VirtualHost></VirtualHost>
apache里面使用了WSGISocketPrefix,说WSGISocketPrefix不能在VirtualHost中使用。

所以我将 WSGISocketPrefix 移到了 VirtualHost 之外。
这样我得到的错误比 socket-user 更多,我认为这是由 sqlite 版本问题引起的。
这是最后一行错误日志。
django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).

我认为 sqlite 版本错误是由在 VirtualHost 之外使用 WSGISocketPrefix 引起的。我认为它忽略了我的环境。


如果是 chmod 的问题,您能说出应该更改哪个目录吗?我已经尝试了一些目录。


感谢阅读我的问题并提供建议。
这是关于堆栈溢出的第一篇文章,我认为写作技巧会出错。(我用谷歌翻译...)请理解。

标签: pythondjangoapachevirtualenvmod-wsgi

解决方案


推荐阅读