这些 VirtualHost 设置是否适用于 Django?
Are these VirtualHost settings workable with Django?
我正在客户网站上部署 Django 应用程序,无法直接访问 httpd.conf 文件。站点支持为我创建了以下内容,但似乎没有任何 STATIC_ROOT 和 STATIC_URL 的组合可供我使用。有可能吗?
注意:Django/Python 页面在 subdomain.mywebsite.com 上运行良好——我只缺少静态文件。 (很抱歉混淆了 URL 和 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'
只需删除静态后的斜线,我遇到了同样的问题,结果是静态后出现了额外的斜线。
Alias /static /home/httpd/html/subdomain.mywebsite.com/public_html/static/
正如 OP 在评论中提到的那样,删除 ProxyPass 有帮助。
ProxyPass / http://127.0.0.1:8000/
我正在客户网站上部署 Django 应用程序,无法直接访问 httpd.conf 文件。站点支持为我创建了以下内容,但似乎没有任何 STATIC_ROOT 和 STATIC_URL 的组合可供我使用。有可能吗?
注意:Django/Python 页面在 subdomain.mywebsite.com 上运行良好——我只缺少静态文件。 (很抱歉混淆了 URL 和 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'
只需删除静态后的斜线,我遇到了同样的问题,结果是静态后出现了额外的斜线。
Alias /static /home/httpd/html/subdomain.mywebsite.com/public_html/static/
正如 OP 在评论中提到的那样,删除 ProxyPass 有帮助。
ProxyPass / http://127.0.0.1:8000/