首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >金字塔扇静态应用程序在apache wsgi模块下找不到静态资源。

金字塔扇静态应用程序在apache wsgi模块下找不到静态资源。
EN

Stack Overflow用户
提问于 2014-06-06 14:37:11
回答 2查看 350关注 0票数 1

我使用pcreate创建了一个金字塔扇静态应用程序:

代码语言:javascript
复制
pcreate -s starter -s pyramid_fanstatic

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

代码语言:javascript
复制
<link rel="stylesheet" type="text/css" href="/fanstatic/services/bootstrap/bootstrap.min.css" />

返回Apache未找到的404。

这是我的WSGI应用程序:

代码语言:javascript
复制
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文件:

代码语言:javascript
复制
<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包含我的资源目录:

代码语言:javascript
复制
"""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也找不到扇静态资源。

我还在ini文件中添加了以下内容:

代码语言:javascript
复制
[filter:fanstatic]
use = egg:fanstatic#fanstatic

[pipeline:main]
pipeline = fanstatic services

我还应该检查/做什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-06-09 09:37:51

修好了!!

我不得不在app:main中将这一行添加到ini文件中。

代码语言:javascript
复制
fanstatic.publisher_signature = fanstatic
fanstatic.use_application_uri = true

根据以下文档:fanstatic

票数 1
EN

Stack Overflow用户

发布于 2014-06-07 03:52:27

您似乎并没有让Apache提供您的静态文件。请参见:

  • Files
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24084446

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档