ngnix 作为django项目的web服务器

来源:互联网 发布:动脑学院 java 百度云 编辑:程序博客网 时间:2024/05/20 03:46

钩子:       

          How To Install Nginx on Ubuntu 14.04 LTS

         基于nginx和uWSGI在Ubuntu上部署Django



1. sudo vi /etc/nginx/nginx.conf 
        ##        # Virtual Host Configs        ##        include /etc/nginx/conf.d/*.conf;        include /etc/nginx/sites-enabled/*;
2. sudo vi /etc/nginx/sites-enabled/default 
         # Make site accessible from http://localhost/         #server_name localhost;        location / {                # First attempt to serve request as file, then                # as directory, then fall back to displaying a 404.                 proxy_pass  http://127.0.0.1:8000;                 proxy_set_header X-Real-IP $remote_addr;                 # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;                 proxy_set_header Host $http_host;                #try_files $uri $uri/ =404;                # Uncomment to enable naxsi on this location                # include /etc/nginx/naxsi.rules        }
3. sudo nginx -t (查看nginx语法,并返回详细错误)

   sudo nginx -h (不懂就查)