首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mod_wsgi -权限被拒绝-无法启动Python

mod_wsgi -权限被拒绝-无法启动Python
EN

Stack Overflow用户
提问于 2021-10-26 23:15:57
回答 1查看 804关注 0票数 0

我试图在运行Ubuntu20.04的非托管VPS上运行django。我连接到刚安装的服务器,安装了Django和Postresql。Apache已经安装好了。然后我安装了mod_wsgi。然后,我尝试配置我的.conf文件。编辑的文件etc\apache2\sites-available\000-default.conf包括以下内容:

代码语言:javascript
复制
    Alias /static /root/django-apps/dmsemapping/staticfiles
    <Directory /root/django-apps/dmsemapping/staticfiles>
        Require all granted
    </Directory>

    <Directory /root/django-apps/dmsemapping/dmsemapping>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess dmsemapping python-path=/root/django-apps/dmsemapping python-home=/root/django-apps/env
    WSGIProcessGroup dmsemapping
    WSGIScriptAlias / /root/django-apps/dmsemapping/dmsemapping/wsgi.py

dmsemapping是我的django项目的名称,/root/django-apps/dmsemapping是我的项目的路径,/root/django-apps/env是我的环境变量的路径。

当我运行这个程序时,我会得到一个403错误。在error.log文件中,我得到:

代码语言:javascript
复制
Current thread 0x00007f84dde19c40 (most recent call first):
<no Python frame>
[Tue Oct 26 22:55:44.887129 2021] [wsgi:warn] [pid 12089:tid 140208634960960] (13)Permission denied: mod_wsgi (pid=12089): Unable to stat Python home /root/django-apps/env. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
Python path configuration:
  PYTHONHOME = '/root/django-apps/env'
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/root/django-apps/env'
  sys.base_exec_prefix = '/root/django-apps/env'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/root/django-apps/env'
  sys.exec_prefix = '/root/django-apps/env'
  sys.path = [
    '/root/django-apps/env/lib/python38.zip',
    '/root/django-apps/env/lib/python3.8',
    '/root/django-apps/env/lib/python3.8/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

任何关于下一步要尝试什么的建议都将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2022-09-02 14:54:24

我通过更改myuser文件夹的权限解决了同样的问题

代码语言:javascript
复制
sudo chmod 755 /home/<user>

实际上,是从这里来的:https://www.linode.com/community/questions/22951/no-python-frame-error-while-trying-to-connect-to-apache-on-mod_wsgi-in-ubuntu

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69730963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档