gpt4 book ai didi

python - Apache - 部署 Django 应用程序时出现错误 403 Forbidden

转载 作者:行者123 更新时间:2023-12-04 19:40:40 25 4
gpt4 key购买 nike

我正在尝试在 Apache 中部署我的 Django 应用程序,但这是不可能的。当我输入网址时,它显示 403 Forbidden 并且没有任何 react 。
我已尝试观看许多教程,但无法修复我的错误。我正在使用 CentOS 7。
这是我的 site.com.conf =>/usr/local/apache/conf.d/vhost/myproject.com.conf

<VirtualHost myprojectIP:8181>
ServerName myproject.com
ServerAlias www.myproject.com
ServerAdmin myproject@myproject.com
DocumentRoot /var/www/html/myproject
UseCanonicalName Off
ScriptAlias /cgi-bin/ /home/admin/public_html/cgi-bin/

<IfModule mod_setenvif.c>
SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
</IfModule>

<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled admin
</IfModule>

<IfModule mod_suexec.c>
SuexecUserGroup admin admin
</IfModule>

<IfModule mod_suphp.c>
suPHP_UserGroup admin admin
suPHP_ConfigPath /home/admin
</IfModule>

<IfModule mod_ruid2.c>
RMode config
RUidGid admin admin
</IfModule>

<IfModule itk.c>
AssignUserID admin admin
</IfModule>

<Directory /var/www/html/myproject>
Options -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
SSLRequireSSL
</Directory>

<Directory /var/www/html/venv>
Require all granted
</Directory>

Alias /static /var/www/html/myproject/templates/static
<Directory /home/admin/public_html/myproject/templates/static>
Require all granted
</Directory>

WSGIProcessGroup remesas
WSGIScriptAlias / /var/www/html/myproject/remesas/wsgi.py

</VirtualHost>


这是我的 site.com.ssl.conf =>/usr/local/apache/conf.d/vhost/myproject.com.ssl.conf
<VirtualHost myprojectIP:8443>
ServerName myproject.com
ServerAlias www.myproject.com
ServerAdmin myproject@myproject.com
DocumentRoot /var/www/html/myproject
UseCanonicalName Off
ScriptAlias /cgi-bin/ /home/admin/public_html/cgi-bin/

#SSL CONFIGURE HERE

####################

<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled admin
</IfModule>

<IfModule mod_suexec.c>
SuexecUserGroup admin admin
</IfModule>

<IfModule mod_suphp.c>
suPHP_UserGroup admin admin
suPHP_ConfigPath /home/admin
</IfModule>

<IfModule mod_ruid2.c>
RMode config
RUidGid admin admin
</IfModule>

<IfModule itk.c>
AssignUserID admin admin
</IfModule>

<Directory /var/www/html/myproject>
Options -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
SSLRequireSSL
</Directory>

<Directory /var/www/html/venv>
Require all granted
</Directory>

Alias /static /var/www/html/myproject/templates/static
<Directory /home/admin/public_html/myproject/templates/static>
Require all granted
</Directory>

WSGIDaemonProcess remesas python-path=/var/www/html/myproject:/var/www/html/venv/lib/python3.6/site-packages
WSGIProcessGroup remesas
WSGIScriptAlias / /var/www/html/myproject/remesas/wsgi.py


</VirtualHost>

最佳答案

在/var/www/html 目录中部署应用程序是不安全的,因为它是默认的 apache 文件夹。检查您的 apache 日志 (error.log) 和 django 文件夹权限。

关于python - Apache - 部署 Django 应用程序时出现错误 403 Forbidden,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63728689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com