在AWS EC2上使用Nginx + uWSGI为Pyramid应用程序提供问题

时间:2016-05-03 06:05:40

标签: nginx amazon-ec2 pyramid uwsgi

尝试在我可以运行nginx的AWS EC2实例上提供金字塔应用程序时遇到一些问题,当我尝试使用AWS提供的URL访问该站点时,我可以看到Nginx的默认网页。但是,当我尝试使用以下命令提供金字塔应用程序时,浏览器仍然显示nginx网页而不是金字塔网页。

登录AWS ssh后,我用于为金字塔应用程序提供服务的命令是:

$ /home/ec2-user/env/bin/uwsgi --ini-paste-logged /home/ec2-user/env/FRuler/production.ini

/etc/nginx/nginx.conf

的设置
user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;

    server {
        listen          <my.aws.ip.address>:80;
        server_name     <my.aws.url.address> <my.domain.address>;
        index           index.html index.htm index.py;
        access_log  /var/log/nginx/<my.domain.address>.log;
        error_log   /var/log/nginx/<my.domain.address.log>.error;
        root            /home/ec2-user/;
        charset         utf-8;

        location / {
            uwsgi_pass  127.0.0.1:3003;
            include     uwsgi_params;
        }

        location /static {
            root        /home/ec2-user/env/FRuler/fruler/;
        }
    }

}

/home/ec2-user/env/FRuler/production.ini

的设置
###
# app configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.6-branch/narr/environment.html
###

[app:main]
use = egg:FRuler

pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en

###
# wsgi server configuration
###

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

###
# logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.6-branch/narr/logging.html
###

[loggers]
keys = root, fruler

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console

[logger_fruler]
level = WARN
handlers =
qualname = fruler

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

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


[uwsgi]
socket = 127.0.0.1:3003
virtualenv = /home/ec2-user/env
die-on-term = 1
master = 1
logto = /home/ec2-user/env/FRuler/uwsgi.log
pidfile = /home/ec2-user/env/FRuler/pid_5000.pid
processes = 4

harakiri = 30
harakiri-verbose = true
limit-post = 5242880
post-buffering = 8192

mypaste = /home/ec2-user/env/FRuler/production.ini
paste = config:%(mypaste)
paste-logger = %(mypaste)

当我尝试使用以下方式提供金字塔应用时:

$ /home/ec2-user/env/bin/uwsgi --ini-paste-logged /home/ec2-user/env/FRuler/production.ini

金字塔默认网页未显示,此后没有命令提示符。

然后我还尝试关闭终端窗口,当我尝试通过ssh重新登录AWS并执行以下命令时:

**$ ps ax | grep uwsgi**
31452 ?        S      0:00 /home/ec2-user/env/bin/uwsgi --ini-paste-logged /home/ec2-user/env/FRuler/production.ini
31463 ?        S      0:00 /home/ec2-user/env/bin/uwsgi --ini-paste-logged /home/ec2-user/env/FRuler/production.ini
31464 ?        S      0:00 /home/ec2-user/env/bin/uwsgi --ini-paste-logged /home/ec2-user/env/FRuler/production.ini
31465 ?        S      0:00 /home/ec2-user/env/bin/uwsgi --ini-paste-logged /home/ec2-user/env/FRuler/production.ini
31466 ?        S      0:00 /home/ec2-user/env/bin/uwsgi --ini-paste-logged /home/ec2-user/env/FRuler/production.ini
31502 pts/1    S+     0:00 grep --color=auto uwsgi

接下来,我尝试查看/home/ec2-user/env/FRuler/uwsgi.log

*** Starting uWSGI 2.0.12 (64bit) on [Tue May  3 01:46:49 2016] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-4) on 19 April 2016 04:32:58
os: Linux-3.10.0-327.el7.x86_64 #1 SMP Thu Oct 29 17:29:29 EDT 2015
nodename: <aws.internal.ip.address>
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /home/ec2-user
writing pidfile to /home/ec2-user/env/FRuler/pid_5000.pid
detected binary path: /home/ec2-user/env/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your processes number limit is 3824
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:3003 fd 3
Python version: 3.4.1 (default, Apr 19 2016, 02:22:12)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
Set PythonHome to /home/ec2-user/env
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x12768f0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 404800 bytes (395 KB) for 4 cores
*** Operational MODE: preforking ***
Loading paste environment: config:/home/ec2-user/env/FRuler/production.ini
ImportError: No module named 'paste.script'
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x12768f0 pid: 31509 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 31509)
spawned uWSGI worker 1 (pid: 31513, cores: 1)
spawned uWSGI worker 2 (pid: 31514, cores: 1)
spawned uWSGI worker 3 (pid: 31515, cores: 1)
spawned uWSGI worker 4 (pid: 31516, cores: 1)

我们在专用的Web服务器上尝试了这种完全相同的设置,没有任何问题(显示金字塔默认网页)。但是,当我们在AWS上尝试它时,它不会提供默认的金字塔默认页面。

非常感谢任何建议。

0 个答案:

没有答案