我正在尝试将金字塔应用程序推广到生产站点。
到目前为止,我已经在 public_html 之外创建了应用程序所在的 env 文件,如下所示:
[~/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
在我的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 error_log 中,它显示:
[Sun Apr 07 23:17:47 2013] [alert] [client <ip_address>]
/home/vretnet9/public_html/.htaccess: WSGIScriptAlias not allowed here
所以我继续看一下 .htaccess
.htaccess
Options +ExecCGI
AddHandler cgi-script .cgi
AddHandler wsgi-script .wsgi
WSGIScriptAlias ECommerce /home/vretnet9/modwsgi/env/pyramid.wsgi
WSGIDaemonProcess root processes=5 threads=1 display-name=%{GROUP}
WSGIProcessGroup root
WSGIApplicationGroup %{GLOBAL}
我不知道它是否真的应该调用 .htaccess 或者脚本别名是否应该与位于我的 .conf 中的相同
/usr/local/apache/conf/userdata/std/1/$user/$domain/modwsgi.conf
modwsgi.conf 的内容如下:
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>
编辑 在 apache error_log 中,正在记录以下内容:
[Mon Apr 08 02:17:22 2013] [error] Traceback (most recent call last):
[Mon Apr 08 02:17:22 2013] [error] File
"/home/vretnet9/modwsgi/env/pyramid.wsgi", line 5, in <module>
[Mon Apr 08 02:17:22 2013] [error] from pyramid.paster import get_app,
setup_logging
[Mon Apr 08 02:17:22 2013] [error] File "/home/vretnet9/modwsgi/env/
lib/python3.3/site-packages/pyramid/paster.py", line 1, in <module>
[Mon Apr 08 02:17:22 2013] [error] import os
[Mon Apr 08 02:17:22 2013] [error] ImportError: No module named os
编辑#2
这是我在 shell 中运行时的结果:
[~/modwsgi/env]# python
Python 3.3.0 (default, Mar 27 2013, 09:31:49)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print (os.getcwd())
/home/vretnet9/modwsgi/env