此处nginx、uwsgi、django的安装就不详说了。只讲核心的配置。
django项目路径:/home/www/mysite
部部署分以下几个步骤:
1、确保django项目的正常运行
python manager.py runserver 0.0.0.0:8000
确定浏览器可正常访问。
2、测试uwsgi与django连接,是否正常。
测试uwsgi, 写一个test.py
# test.py def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) return "Hello World"
然后执行shell命令:
uwsgi --http :8001 --wsgi-file test.py curl localhsot:8001 curl localhost:8001 -I 测试是否成功。 用uwsgi起动mysite uwsgi -s 127.0.0.1:9090 -w demo 3、nginx的配置 vim nginx.conf server { listen 80 default_server; server_name test.com localhost; location / { include uwsgi_params; uwsgi_pass 127.0.0.1:9090; } } 完成后,在浏览器中进行测试。