2011-08-29 119 views
2

你好,我正在运行web2py nginx和uwsgi,但我遇到了部署1个或多个域的问题。问题是服务器总是返回默认的欢迎应用程序,而不是我为域指定的文件夹Web2py nginx和域名

任何想法,非常感谢。这里是我的nginx.conf文件(相关部分)

server { 
    listen  80; 
    server_name www.cheer10s.com cheer10s.com; 

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

    location /static { 
     root /opt/web2py/applications/cheer10s/; 
    } 
} 

server { 
    listen  443; 
    server_name www.cheer10s.com cheer10s.com; 
    ssl     on; 
    ssl_certificate  /opt/nginx/conf/server.crt; 
    ssl_certificate_key /opt/nginx/conf/server.key; 

    location/{ 
     uwsgi_pass  127.0.0.1:9001; 
     include   uwsgi_params; 
     uwsgi_param  UWSGI_SCHEME $scheme; 
    } 

    location /static { 
     root /opt/web2py/applications/cheer10s/; 
    } 
} 

*欢呼

回答

3

此位置:

location /static { 
     root /opt/web2py/applications/cheer10s/; 
    } 

只对静态文件重写,而不是应用程序,我想这是错误的,必须是:

location ~* /(\w+)/static/ { 
      root /opt/web2py/applications/; 
     } 

上面这行只是服务器文件直接由/ NGINX下的/ static文件夹做没有触及它的web2py。

与uwsgi,该行负责的web2py

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

调用和路由器必须在框架中定义的,而不是在nginx的。如果您想将cheer10s作为默认应用程序,请将routes.py放置在您的web2py根文件夹中。这样看:

routers = dict(

    # base router 
    BASE = dict(
     default_application = 'cheer10s', 
     domains = { 
       'yourdomain.com' : 'cheer10s', 
       'anotherdomain.com':'anotherapp' 
       }, 
     applications = ['cheer10s','anotherapp','admin'], 
     controllers = 'DEFAULT' 
    ), 
) 

保存上述内容在web2py的根文件夹routes.py并重新启动web2py的,但不要忘记,以解决您的nginx的conf。