Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 将金字塔应用程序滚动到生产站点_Python 3.x_Pyramid_Production - Fatal编程技术网

Python 3.x 将金字塔应用程序滚动到生产站点

Python 3.x 将金字塔应用程序滚动到生产站点,python-3.x,pyramid,production,Python 3.x,Pyramid,Production,我正试图在一个生产站点上推出一个金字塔应用程序 到目前为止,我已经创建了env文件,在该文件中,应用程序被放置在公共的html中,如下所示: [~/env] $ 所以我打字了 $ ../bin/pserve production.ini, 但是,当我访问www.mydomain.com时,它仍然显示index.html。我应该如何解决这个问题 我使用的是CentOS 64位+Apache+mod_wsgi 设置如下: Apache/2.2.24 (Unix)

我正试图在一个生产站点上推出一个金字塔应用程序

到目前为止,我已经创建了env文件,在该文件中,应用程序被放置在公共的html中,如下所示:

    [~/env] $
所以我打字了

    $ ../bin/pserve production.ini, 
但是,当我访问www.mydomain.com时,它仍然显示index.html。我应该如何解决这个问题

我使用的是CentOS 64位+Apache+mod_wsgi

设置如下:

    Apache/2.2.24 (Unix) 
    mod_ssl/2.2.24 
    OpenSSL/1.0.0-fips 
    mod_wsgi/3.3 
    Python/2.6.6 
    mod_auth_passthrough/2.1 
    mod_bwlimited/1.4 
    FrontPage/5.0.2.2635 configured -- resuming normal operations
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    WSGIDaemonProcess pyramid user=vretnet9 group=vretnet9 threads=4 \
    python-path=/home/vretnet9/modwsgi/env/lib/python3.3/site-packages
    WSGIScriptAlias /ECommerce /home/vretnet9/modwsgi/env/pyramid.wsgi

    <Directory /home/vretnet9/modwsgi/env>
         WSGIProcessGroup pyramid
         Order allow,deny
         Allow from all
    </Directory>

在我的production.ini文件中,如下所示

    [app:main]
    use = egg:ECommerce
    reload_templates = false
    debug_authorization = false
    debug_notfound = false
    debug_routematch = false
    debug_templates = false
    default_locale_name = en
    mongodb.url = mongodb://my.ip.address
    mongodb.db_name = mycart_demo

    [filter:weberror]
    use = egg:WebError#error_catcher
    debug = false
    ;error_log = 
    ;show_exceptions_in_wsgi_errors = true
    ;smtp_server = localhost
    ;error_email = janitor@example.com
    ;smtp_username = janitor
    ;smtp_password = "janitor's password"
    ;from_address = paste@localhost
    ;error_subject_prefix = "Pyramid Error"
    ;smtp_use_tls =
    ;error_message =

    #[pipeline:main]
    #pipeline =
    #    weberror
    #    ECommerce

    [server:main]
    use = egg:waitress#main
    host = 0.0.0.0
    port = 8080

    # Begin logging configuration

    [loggers]
    keys = root, ecommerce

    [handlers]
    keys = console

    [formatters]
    keys = generic

    [logger_root]
    level = WARN
    handlers = console

    [logger_ecommerce]
    level = WARN
    handlers =
    qualname = ecommerce

    [handler_console]
    class = StreamHandler
    args = (sys.stderr,)
    level = NOTSET
    formatter = generic

    [formatter_generic]
    format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s

    # End logging configuration

我已经设法在一个生产站点上推广,但是,现在,它显示了一个500内部服务器错误

在apache错误日志中,它显示:

    [Sun Apr 07 23:17:47 2013] [alert] [client <ip_address>] 
        /home/vretnet9/public_html/.htaccess: WSGIScriptAlias not allowed here
我不知道它是否应该实际调用.htaccess,或者脚本别名是否应该与位于

    /usr/local/apache/conf/userdata/std/1/$user/$domain/modwsgi.conf
modwsgi.conf的内容如下:

    Apache/2.2.24 (Unix) 
    mod_ssl/2.2.24 
    OpenSSL/1.0.0-fips 
    mod_wsgi/3.3 
    Python/2.6.6 
    mod_auth_passthrough/2.1 
    mod_bwlimited/1.4 
    FrontPage/5.0.2.2635 configured -- resuming normal operations
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    WSGIDaemonProcess pyramid user=vretnet9 group=vretnet9 threads=4 \
    python-path=/home/vretnet9/modwsgi/env/lib/python3.3/site-packages
    WSGIScriptAlias /ECommerce /home/vretnet9/modwsgi/env/pyramid.wsgi

    <Directory /home/vretnet9/modwsgi/env>
         WSGIProcessGroup pyramid
         Order allow,deny
         Allow from all
    </Directory>

这不是使用mod_wsgi+Apache将金字塔项目投入生产的方式。我推荐阅读

当您运行
。/bin/pserve production.ini
时,它会在端口8080处启动一个粘贴HTTP服务器(在
production.ini
中定义)

理想情况下,您需要在一个全新的虚拟环境中安装pyramid,然后配置mod_wsgi以使用该python实例。您必须将
.wsgi
脚本添加到项目中,并配置mod_wsgi以在Apache启动时运行该脚本

编辑

脚本别名(以及所有相关部分)应该在modwsgi.conf中(确保在实际的apache conf中导入modwsgi.conf)

在该文件中,您应该定义PYTHONPATH和PYTHONHOME(特别是如果您有virtualenv)以及您已经定义的其他内容(WSGIApplicationGroup、WSGIScriptAlias等)

重要信息-确保您的apache用户(apache)始终拥有对.wsgi脚本的读取执行权限。这意味着apache甚至可以访问/home目录

我建议creatijg创建一个seapate目录(比如/opt/proj)来托管应用程序,另一个目录(比如/opt/env来托管环境)

下面是我的pyramid.conf的外观。我有Python2.6并将我的项目(仅限于css、图像、js和.wsgi脚本等静态内容)保存在/opt/save_项目中。我的虚拟视频是/opt/pyra

WSGIPythonHome /opt/pyra
WSGIPythonPath /opt/pyra/lib/python2.6
<VirtualHost 31.1.1.22:8005>
    DocumentRoot /opt/save_project
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    WSGIProcessGroup %{GLOBAL}
    WSGIDaemonProcess pyramid user=apache group=apache \
      python-path=/opt/pyra/lib/python2.6
    WSGIScriptAlias / /opt/save_project/pyramid.wsgi
   # Get the static and favicon.ico pages working by properly aliasing them
   Alias /favicon.ico /opt/save_project/static/images/favicon.ico
   Alias /static /opt/save_project/static
   <Directory /opt/save_project>
       AllowOverride all
       Options -MultiViews
   </Directory>
</VirtualHost>
WSGIPythonHome/opt/pyra
WSGIPythonPath/opt/pyra/lib/python2.6
DocumentRoot/opt/save_项目
WSGIApplicationGroup%{GLOBAL}
WSGIPassAuthorization On
WSGIProcessGroup%{GLOBAL}
WSGIDaemonProcess pyramid user=apache组=apache\
python路径=/opt/pyra/lib/python2.6
WSGIScriptAlias//opt/save_project/pyramid.wsgi
#通过对静态页面和favicon.ico页面进行正确的别名处理,使其正常工作
别名/favicon.ico/opt/save_project/static/images/favicon.ico
别名/static/opt/save_项目/static
允许超越所有
选项-多视图

您可能会看到更多信息

您没有说明已经安装了什么服务器。您应该尝试找出nginx没有运行的原因。这可能是因为您的其他服务器应用程序正在使用端口80。检查nginx的日志。此外,nginx运行后,食谱中的这篇文章可能会帮助您进行开发。ini,您的应用程序设置在哪个端口上运行?通常我不认为它默认为80。您可能必须停止默认站点(apache?)并将pyramid应用程序设置为响应端口80?不过,在我的生产服务器上,我相信它也在使用nginix_wsgi@edmicman我已经编辑了这个问题啊,我忘了添加modwsgi,应该是[~/modwsgi/env],我的错,我按照这里的说明操作:。我被第9项困住了,我将不时地在不同的站点部署应用程序,如果每次我在站点中添加应用程序时都需要重新启动apache,我认为这有点荒谬。我需要一些东西,当我运行/bin/pserve MyApp/production.ini时,无论它是在abc.com还是123.com中,它都将启动,而无需重新启动apache。如果我不能重新启动sudoapache呢?问题是,
pserve
启动一个粘贴服务器(或者是waitess?)而不是apache服务器。据我所知,每次安装、升级、修改应用程序配置时,您都必须重新启动apache。您还可以查看指针。实际上,您可以在守护程序模式下运行mod_wsgi,如果.wsgi脚本发生更改,它将自动重新启动应用程序(而不是apache)。请参阅中添加的有关我在部署到生产站点时遇到的错误的更多信息。
WSGIPythonHome /opt/pyra
WSGIPythonPath /opt/pyra/lib/python2.6
<VirtualHost 31.1.1.22:8005>
    DocumentRoot /opt/save_project
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    WSGIProcessGroup %{GLOBAL}
    WSGIDaemonProcess pyramid user=apache group=apache \
      python-path=/opt/pyra/lib/python2.6
    WSGIScriptAlias / /opt/save_project/pyramid.wsgi
   # Get the static and favicon.ico pages working by properly aliasing them
   Alias /favicon.ico /opt/save_project/static/images/favicon.ico
   Alias /static /opt/save_project/static
   <Directory /opt/save_project>
       AllowOverride all
       Options -MultiViews
   </Directory>
</VirtualHost>