【问题标题】:Deploying Django app : Forbidden You don't have permission to access this resource部署 Django 应用程序:禁止您无权访问此资源
【发布时间】:2021-12-06 16:25:47
【问题描述】:

我正在使用 apache Web 服务器在我的 VPS 上部署我的 django 应用程序。 它在http://192.46.209.82:8000/ 上完全可以正常工作,但是当我尝试使用我的IP 地址192.46.209.82 访问它时。我明白了

Forbidden
You don't have permission to access this resource.

Apache/2.4.41 (Ubuntu) Server at 192.46.209.82 Port 80

这是我的配置文件

nano /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
        ServerAdmin webmaster@example.com
        DocumentRoot /root/django/myproject
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        Alias /static /root/django/myproject/static
        <Directory /root/django/myproject/static>
                Require all granted
        </Directory>
        <Directory /root/django/myproject/myproject>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>
        WSGIDaemonProcess myproject python-path=/root/django/myproject python-home=/root/django/myprojectenv
        WSGIProcessGroup myproject
        WSGIScriptAlias / /root/django/myproject/myproject/wsgi.py
</VirtualHost>

我使用的是python的虚拟环境,其中myprojectenv是我的虚拟环境路径,pwd是/root/django

注意:我尝试了从问题中得到的作为对这个问题的建议的答案,但这对我不起作用。

编辑:更新权限

【问题讨论】:

    标签: python django apache mod-wsgi wsgi


    【解决方案1】:

    在我的情况下,即使我正确设置了所有权限,我仍然遇到错误,因此我将整个项目和虚拟环境移动到 /opt,它现在对我有用。但我想知道为什么它在/home 下无法工作,即使我授予了所有权限

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-26
      • 2021-06-23
      • 1970-01-01
      • 2021-06-21
      • 2020-07-05
      • 1970-01-01
      • 2020-05-07
      相关资源
      最近更新 更多