- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这不像其他问题那么简单……至少。设置简单的基于单一目录的静态文件位置不是问题..
https://bitbucket.org/sirex/django-starter/src
这里有一个非常有趣的项目。这个项目使用 distribute 和 buildout 在一个目录中制作整个项目和带有模块的 django。您可以轻松地从开发模式迁移到生产模式等等。您只需要重命名目录,然后在其中键入“make”,就是这样=)那里有手册...
适用于 python 服务器但不适用于 apache mod_wsgi 的情况:默认的静态文件位置是:“var/htdocs/static”。这可以用一个静态目录位置覆盖,例如 apps/myapp/myapp/static/。这适用于 python 网络服务器,但不适用于 wsgi/apache。 wsgi 除了默认目录外什么都看不到。例如:http://localhost:8000/static/css/main.css有效,但与 apache 相同的 url 不起作用。这个文件位于 myproject/apps/myapp/myapp/static/css/main.css 虽然默认静态目录是 var/htdocs/static =)
据我所知,这个覆盖是在 settings.py 中使用 StaticFiles 应用程序进行的
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BUILDOUT_DIR, 'var', 'htdocs', 'static')
STATICFILES_DIRS = (
os.path.join(BUILDOUT_DIR, 'project', 'static'), # <-- why "project" and not "apps" I don't know X_X
)
也许这个是不正确的,我不知道,但是对于 py-server 这可行。 apache vhost 使用默认位置.. 并设置为“var/htdocs/static”。
也许问题出在 wsgi 脚本中?
#!/usr/local/bin/python2.6
import os,sys
sys.path[0:0] = [
'/usr/local/lib/python2.6/site-packages/',
'/www/webapp/visimes/eggs/PIL-1.1.7-py2.6-freebsd-8.1-RELEASE-amd64.egg',
'/www/webapp/visimes/eggs/South-0.7.3-py2.6.egg',
'/www/webapp/visimes/eggs/django_annoying-0.7.6-py2.6.egg',
'/www/webapp/visimes/eggs/coverage-3.4-py2.6-freebsd-8.1-RELEASE-amd64.egg',
'/www/webapp/visimes/eggs/django_debug_toolbar-0.8.4-py2.6.egg',
'/www/webapp/visimes/eggs/django_extensions-0.6-py2.6.egg',
'/www/webapp/visimes/eggs/django_test_utils-0.3-py2.6.egg',
'/www/webapp/visimes/eggs/ipdb-0.3-py2.6.egg',
'/www/webapp/visimes/eggs/ipython-0.10.1-py2.6.egg',
'/www/webapp/visimes/eggs/djangorecipe-0.21-py2.6.egg',
'/www/webapp/visimes/eggs/zc.recipe.egg-1.3.2-py2.6.egg',
'/www/webapp/visimes/eggs/zc.buildout-1.5.2-py2.6.egg',
'/www/webapp/visimes/eggs/BeautifulSoup-3.2.0-py2.6.egg',
'/www/webapp/visimes/eggs/setuptools-0.6c12dev_r88795-py2.6.egg',
'/www/webapp/visimes/parts/django',
'/www/webapp/visimes',
'/www/webapp/visimes/project', # <-- this one need for monitor.py which i put in there
'/www/webapp/visimes/apps/portal', # <-- startapp.sh script some how forgot to add this dir, it's my default app dir, which must be generated with startapp.sh and added in here..
]
import djangorecipe.wsgi
if __name__ == '__main__':
djangorecipe.manage.main('project.development')
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.development'
import monitor
monitor.start(interval=1.0)
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我自己添加了最后 4 行。因为我无法启动 apache.. 我猜 djangorecipe.wsgi 应该用 staticFile override 处理其他所有事情.. 不管怎样,请检查那个包,如果你在 linux 或 mac 上,然后自己尝试。它必须工作
附言。 (顺便说一句,bin/django 需要复制为 bin/django.wsgi 并且 etc/apache.conf 是为 apache 生成的 vhost)
如果有人会尝试使用 wsgi 手动启动这个“Starter”,我真的很感激......那么你就会明白一切。=)
编辑:关于 WSGI 如何理解他需要从 django 设置中搜索静态文件的默认位置的任何信息,非常感谢 =)
最佳答案
在官方 mod_wsgi 站点上有很多文档可以帮助您了解如何使用它。这包括如何设置它以提供静态媒体文件。见:
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines
关于Django StaticFiles APP 和 Wsgi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5576511/
我正在尝试了解 WSGI 的功能并需要一些帮助。 到目前为止,我知道它是一种服务器和应用程序之间的中间件,用于将不同的应用程序框架(位于服务器端)与应用程序连接,前提是相关框架具有 WSGI 适配器。
正如之前多个问题/答案中所强调的,即this和 this我已将 WSGISocketPrefix 配置为 /etc/httpd/run/wsgi /etc/httpd/run目录具有root:apac
正如之前多个问题/答案中所强调的,即this和 this我已将 WSGISocketPrefix 配置为 /etc/httpd/run/wsgi /etc/httpd/run目录具有root:apac
我刚刚开始使用协同程序,并阅读了有关 gevent 和 greenlets 的内容。为了进行测试,我通过 gevents pywsgi 模块提供了这段代码: from gevent.pywsgi im
我正在尝试了解 WSGI 的工作原理。我知道我可以阅读规范,但我仍然想知道如何创建 spawning应用?一个完整的“ Hello World ”。 有人可以给我举个例子吗?有了一切,文件命名,创建模
我正在构建一个简单的 Web 服务,要求对所有请求进行签名。签名哈希是使用包括请求正文的请求数据生成的。我的愿望是拥有一个验证请求签名的中间件组件,如果签名无效则以错误响应。问题是中间件需要使用 en
为什么会出现此错误? Daemon process called 'dom_server' cannot be accessed by this WSGI application: /home/sta
HTTP格式 HTTP GET请求的格式: ? 1
我读过很多类似 this one 的帖子详细说明如何使用 WSGI 动态返回图像。但是,我看到的所有示例都是以二进制格式打开图像,读取它然后返回该数据(这对我来说很好用)。 我一直在尝试使用内存中的
我正在尝试使用 Apache 为我的网页提供服务,并且想知道 wsgi.py 和 django.wsgi 之间的区别。 两者都有文档,但我不确定应该实现哪一个。我在 Django 1.4、Apache
我正在尝试使用 uwsgi 运行 Django 应用程序。我发现的大多数指令都引用了“--wsgi-file”和“--module”来指定应用程序,但是“uwsgi”没有提到这些选项,当我尝试使用它们
我对以下术语感到非常困惑, 1.wsgi 2.python_wsgi 3.wsgi服务器 4. mod_wsgi 5. python web服务器网关接口(interface)(PEP3333) 这些
我通过如下设置 apache 服务器在 apache2/Mac OS X 上使用 mod_wsgi。 Order allow,deny Allow from all WSGIScri
对于我们的网络服务,我编写了一些逻辑来防止 multipart/form-data POST 大于 4mb。 它归结为以下内容(我已经剥离了所有 WebOb 用法并将其简化为普通的 WSGI 代码):
我有一个 Flask Web 服务器,为使用 Flask-login 的用户进行基本帐户身份验证。如果我自己运行网络服务器,帐户身份验证将按预期工作。使用 Apache 和 mod-wsgi 运行 F
我在 centos 6.9 机器上使用 httpd 和 mod_wsgi 和 httpd 这里是相关文件,我正在尝试在 apache 2.15 版本上部署 django,尝试谷歌但无法解决问题,任何帮
我将在虚拟主机的 ubuntu 服务器上设置一个 django 应用程序。 我已经配置了我的虚拟主机,所以出现了一些问题! 但是由于您在此处看到的一些问题,它仍然给我 500 内部错误: mod_ws
我有一个相当简单、朴素的 Python/WSGI/Pyramid 网络服务器。 它在使用 pyramid.config.Configurator().make_wsgi_app() 构建的服务器上使用
我试图在 Amazon 的 EC2 实例上发布我的网站,但我一直收到 500 错误。我真的不知道为什么。 //日志文件 [Sun Feb 17 23:12:48.066802 2013] mo
我正在尝试在 ubuntu 上的 apache2 上安装 mod_wsgi。所以我安装了 libapache2-mod-wsgi 包,我用 a2enmod 激活了他。 我有一个网站 (language
我是一名优秀的程序员,十分优秀!