简体   繁体   English

从本地主机金字塔生活

[英]pyramid from localhost to live

Hi guys I am having some trouble here and so i'm asking for some advise. 嗨,大家好,我在这里遇到了麻烦,所以我想请教一些建议。

I built a pyramid app, it works perfectly on localhost, now I'm uploading it to a vps and i'm running into all kinds of trouble. 我构建了一个金字塔应用程序,它在localhost上完美运行,现在我将其上传到vps,遇到了各种各样的麻烦。 My site is hosted on mercurial. 我的网站托管在mercurial上。

please don't reference this: http://docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/modwsgi/index.html 请不要引用此内容: http : //docs.pylonsproject.org/projects/pyramid/zh-CN/latest/tutorials/modwsgi/index.html

I've tried that many times and Googled a lot, that's why I'm asking the question here. 我已经尝试了很多次,并且使用Google搜索了很多次,这就是为什么我在这里问这个问题。

I'm on python 2.7 我在python 2.7上

  1. I create a virtualenv 我创建一个virtualenv
  2. activate the virtualenv 激活虚拟环境
  3. pip -r requirements to download all the requirements pip -r要求下载所有要求
  4. then python setup.py install 然后python setup.py安装

I now have a folder structure like this: 我现在有一个像这样的文件夹结构:

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

keep in mind I didn't name my folders appname_dir and appname_module. 请记住,我没有将文件夹命名为appname_dir和appname_module。

I create my app.wsgi file inside my appname_module folder it looks like this 我在我的appname_module文件夹中创建我的app.wsgi文件,它看起来像这样

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

I've tried creating a virtual host file similar to the one below 我尝试创建类似于下面的虚拟主机文件

<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>

that doesn't work 那行不通

I've tried to add custom apache conf file similar to the one below 我尝试添加类似于以下内容的自定义apache conf文件

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>

and still no go. 还是没有去。 Typically their a 500 error with this code in the apache error log files 通常,此错误是apache错误日志文件中的此代码的500错误

Target WSGI script cannot be loaded as Python module

can anyone help explain what's going on or how I can fix this. 任何人都可以帮助解释发生了什么或如何解决此问题。 Please pointing me to other SO answers isn't helpful I've spent all day trying to figure this out. 请整日试图找出答案的其他有用答案对我没有帮助。

Well I was able to solve the problem by moving away from apache and mod_wsgi, I setup nginx and uwsgi. 好吧,我能够通过离开apache和mod_wsgi来解决问题,我设置了nginx和uwsgi。 If I need apache I can proxy connections from nginx to apache but I don't see me needing to take that route anytime soon. 如果我需要apache,我可以代理从nginx到apache的连接,但是我不认为我需要尽快采用该路由。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM