【发布时间】: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