从localhost到li的金字塔

2024-04-19 18:14:52 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,伙计们,我在这里遇到了一些麻烦,所以我请求一些建议。你知道吗

我建立了一个金字塔应用程序,它在localhost上运行得非常好,现在我把它上传到一个vps上,我遇到了各种各样的麻烦。我的网站托管在mercurial上。你知道吗

请不要引用此:http://docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/modwsgi/index.html

我已经试过很多次了,搜索了很多,这就是为什么我要问这个问题。你知道吗

我使用的是python2.7

  1. 我创造了一个虚拟世界
  2. 激活virtualenv
  3. 下载pip-r要求的所有要求
  4. 然后是Python设置.py安装

我现在有这样一个文件夹结构:

appname_dir/
     appname_module/
        static/
        template/
        __init__.py
        views.py

请记住,我没有命名我的文件夹appname\u dir和appname\u module。你知道吗

我创建我的应用程序.wsgi在我的appname\u模块文件夹中

from pyramid.paster import get_app, setup_logging
ipath = '/path/to/appname_dir/production.ini'
application = get_app(ipath, 'main')

我尝试创建一个类似于下面的虚拟主机文件

<VirtualHost *:80>
        ServerAdmin contact@domain.com
        ServerName domain.com
        ServerAlias www.domain.com

        UseCanonicalName On

        WSGIScriptAlias / /path/to/my/app.wsgi
        <Directory /path/to/folder/that/contains/app.wsgi>
                Order allow,deny
                Allow from all
        </Directory>

        Alias /static /path/to/app/static/folder
        <Directory /path/to/app/static/folder>
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog /path/to/app/folder/logs/error.log
        LogLevel warn
        CustomLog /path/to/app/folder/logs/access.log combined
</VirtualHost>

那不行

我尝试添加与下面类似的定制apacheconf文件

WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess pyramid user=username group=groupname threads=6 \
   python-path=/path/to/virtualenv/site-packages
WSGIScriptAlias / /path/to/app.wsgi

<Directory /path/to/appname_dir>
  WSGIProcessGroup pyramid
  Order allow,deny
  Allow from all
</Directory>

还是不行。通常,他们在apache错误日志文件中会发现500个错误

Target WSGI script cannot be loaded as Python module

有人能帮我解释一下发生了什么事,或者我怎么能解决这个问题吗。请给我指出其他答案,这样对我没什么帮助,我花了一整天的时间想弄明白。你知道吗


Tags: 文件topathfrompy文件夹pyramidapp
1条回答
网友
1楼 · 发布于 2024-04-19 18:14:52

好吧,我能够解决这个问题,离开apache和mod\uwsgi,我设置了nginx和uwsgi。如果我需要apache,我可以代理从nginx到apache的连接,但我不认为我需要走这条路线很快。你知道吗

相关问题 更多 >