python - Pyramid - fanstatic应用程序在apache wsgi模块下找不到静态资源

标签 python apache mod-wsgi pyramid fanstatic

我有一个使用 pcreate 创建的 Pyramid-Fanstatic 应用程序:

pcreate -s starter -s pyramid_fanstatic

如果我使用/bin/pserve-fanstatic 启动服务器,一切正常。但是,当我使用 Apache WSGI 模块加载应用程序时,会出现如下链接:

<link rel="stylesheet" type="text/css" href="/fanstatic/services/bootstrap/bootstrap.min.css" />

返回 404 Not Found by Apache。

这是我的 WSGI 应用程序:

import os
activate_this = os.path.join('/opt/services/services/bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
os.environ['PYTHON_EGG_CACHE'] = '/opt/services/python-eggs'


from pyramid.paster import get_app, setup_logging
ini_path = '/opt/services/services/development.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main') 

这是我的 Apache conf 文件:

<VirtualHost *:80>
    ServerAdmin a.orth@cgiar.org
    ServerName data.ilri.org

    # Pass authorization info on (needed for rest api).
    WSGIPassAuthorization On

    WSGIDaemonProcess services python-path=/opt/services/services display-name=services processes=2 threads=15
    WSGIScriptAlias /services /opt/services/services/services/services.wsgi process-group=services application-group=%{GLOBAL}

    <Location /services>
                WSGIProcessGroup services
    </Location>

    ErrorLog /var/log/httpd/services.error.log
    CustomLog /var/log/httpd/services.custom.log combined

</VirtualHost>

我可以看到/bin/pserve-fanstatic 在加载应用程序之前包含我的资源目录:

"""A script aware of static resource"""
    import pyramid.scripts.pserve
    import pyramid_fanstatic
    import os

    dirname = os.path.dirname(__file__)
    dirname = os.path.join(dirname, 'resources')
    pyramid.scripts.pserve.add_file_callback(
                pyramid_fanstatic.file_callback(dirname))
    pyramid.scripts.pserve.main()

但即使我在 init.py 中包含这些行,Apache 也无法找到 fanstatic 资源。

我还将其添加到我的 ini 文件中:

[filter:fanstatic]
use = egg:fanstatic#fanstatic

[pipeline:main]
pipeline = fanstatic services

我还应该检查/做什么?

最佳答案

您似乎没有告诉 Apache 提供您的静态文件。请参阅:

关于python - Pyramid - fanstatic应用程序在apache wsgi模块下找不到静态资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24084446/

相关文章:

python - Seabornpairplot 色调参数未按预期工作

python - 下载数据集 : ValueError: I/O operation on closed file 时出现此错误

python - 使用 python 连接到域以确定服务器是否在线

python - Django 自定义管理 admin.site.register + admin.site.unregister 在第一个 HTTP GET 上与 AlreadyRegistered + NotRegistered 发生冲突(Apache + mod WSGI)

Django/mod_wsgi/postgresql_psycopg2 : can't connect authentication fails (but settings work fine under django runserver or dbshell)

python - 在 numpy 中创建 "white"图像(二维图像)

php - 使 apache 别名指向 trucrypt 容器中的文件夹

php - Yii2 自定义 url 管理。出现 400 错误

apache - 如何将 https ://example. com/重定向到 https ://www. example.com/

python - 如果我使用 mod_wsgi 来提供应用程序,在哪里可以看到标准输出?