简体   繁体   English

在Apache虚拟主机上部署Django:404

[英]Deploy Django on Apache virtual host: 404

I know there are a lot of articles talking about this issue, but I keep getting a 404 error when deploying a Django site through Apache virtual host. 我知道有很多关于此问题的文章,但是通过Apache虚拟主机部署Django站点时,我总是收到404错误。 Here is my .conf file: 这是我的.conf文件:

Listen 8001
<VirtualHost *:8001>
  ServerName www.myhostname.com/basic
  ServerAdmin caisj@example.com

  ProxyRequests Off
  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>

  DocumentRoot /home/browser/BASIC/basic

  Alias /static /home/browser/BASIC/basic/static
  Alias /media /home/browser/BASIC/_py/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/contrib/admin/media

  WSGIScriptAlias /basic /home/browser/BASIC/basic/basic.wsgi
  ErrorLog /home/browser/BASIC/basic/log/basic.error.log

  LogLevel info
  CustomLog /home/browser/BASIC/basic/log/basic.access.log combined
</VirtualHost>

I have tried different combinations of the "ServerName" and other parameters, but when visiting www.myhostname.com/basic, I keep getting a 404 error. 我尝试了“ ServerName”和其他参数的不同组合,但是在访问www.myhostname.com/basic时,出现了404错误。 The Apache restarts successfully and the log file contains no clues. Apache成功重新启动,并且日志文件不包含任何线索。

Or could anybody help to tell where to find errors? 还是有人可以帮助您确定在哪里找到错误? Thanks. 谢谢。

You have set this up to listen on port 8001 and rooted at /basic , so you need to access www.myhostname.com:8001/basic . 您已将其设置为侦听端口8001并以/basic根,因此您需要访问www.myhostname.com:8001/basic

Note that you shouldn't set DocumentRoot to the location of your Django files. 请注意,您不应将DocumentRoot设置为Django文件的位置。 It isn't necessary to serve a Django app, and it could potentially be a security risk - a misconfiguration could mean that your code files, including any db passwords, might be served. 不必提供Django应用程序,这可能会带来安全风险-配置错误可能意味着可能会提供您的代码文件(包括所有数据库密码)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM