你好,我正在运行web2py nginx和uwsgi,但我遇到了部署1个或多个域的问题。 问题是服务器总是返回默认的欢迎应用程序,而不是我为域指定的文件夹
任何想法,不胜感激。 这是我的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/; } }
*干杯
这个位置:
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' ), )
将上面的内容保存为web.py根文件夹中的routes.py,然后重新启动web2py,但不要忘记修复您的nginx conf。