[英]Apache - Error 403 Forbidden when deploying Django app
I am trying to deploy my Django application in Apache but it is impossible.我正在尝试在 Apache 中部署我的 Django 应用程序,但这是不可能的。 When I enter the url it says 403 Forbidden and nothing happens.当我输入 url 时,它说 403 Forbidden 并且没有任何反应。
I have tried watching many tutorials but have not been able to fix my error.我曾尝试观看许多教程,但无法修复我的错误。 I'm using CentOS 7.我正在使用 CentOS 7。
This is my site.com.conf => /usr/local/apache/conf.d/vhost/myproject.com.conf这是我的 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>
This is my site.com.ssl.conf => /usr/local/apache/conf.d/vhost/myproject.com.ssl.conf这是我的 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>
This is insecure to deploy app at /var/www/html directory, 'cause it is a default apache folder.在 /var/www/html 目录中部署应用程序是不安全的,因为它是默认的 apache 文件夹。 Check your apache logs (error.log) and django folder permissions.检查您的 apache 日志 (error.log) 和 django 文件夹权限。
there are 2 common error about this, check these:关于此有 2 个常见错误,请检查这些:
check your url path, Permission and privileges检查您的网址路径、权限和特权
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.