这些VirtualHost设置是否可以与Django一起使用?
问题描述:
我在客户端的网站上部署Django应用程序,并没有直接访问httpd.conf文件。网站支持为我创建了以下内容,但似乎没有STATIC_ROOT和STATIC_URL的组合,我可以使用它。它甚至有可能吗?这些VirtualHost设置是否可以与Django一起使用?
注意:Django/Python页面在subdomain.mywebsite.com上的服务很好 - 我只是缺少静态文件。 (对不起,混淆的网址和IP地址...客户端是非常私人的。)
更新1(结尾的斜杠删除 - 仍然无法正常工作)
NameVirtualHost ##.###.###.#
<VirtualHost ##.###.###.#>
DocumentRoot /home/httpd/html/subdomain.mywebsite.com/public_html
ScriptAlias /cgi-bin /home/httpd/html/subdomain.mywebsite.com/cgi-bin
ServerName www.subdomain.mywebsite.com
CustomLog /home/httpd/logs/subdomain.mywebsite.com_access_log combined
ServerAlias subdomain.mywebsite.com
Alias /static/ /home/httpd/html/subdomain.mywebsite.com/public_html/static/
<Directory /home/httpd/html/subdomain.mywebsite.com/public_html/>
allow from all
</Directory>
<Directory /home/httpd/html/subdomain.mywebsite.com/public_html/>
<Files wsgi.py>
allow from all
</Files>
</Directory>
ProxyPreserveHost On
ProxyPass/http://127.0.0.1:8000/
ProxyPassReverse/http://127.0.0.1:8000/
</VirtualHost>
这里就是在我的settings.py文件
STATIC_URL = '/static/'
STATIC_ROOT = '/home/httpd/html/notices.removeyourcontent.com/public_html'
我也试过:
STATIC_ROOT = '/home/httpd/html/notices.removeyourcontent.com/public_html/static'
答
后静态只需删除斜线,我有同样的问题,原来前在静态发布后进行tra斜线。
Alias /static /home/httpd/html/subdomain.mywebsite.com/public_html/static/
另外正如OP在评论中提到的,删除ProxyPass帮助。
ProxyPass/http://127.0.0.1:8000/
谢谢你的建议。试着现在......最初删除了两个斜线,这不是你所建议的。 – evan
@evan做到了吗? – Aki003
你的建议可能有帮助,但ProxyPass系列仍然阻止它的工作。主机上的某个人最终意识到并删除了该行。再次感谢您的建议! – evan