藤席好还是竹席好,赵飞燕皇宫情史,黄圣依兰州演唱会
具体环境:
ubuntu 14.04 python 2.7.6 django 1.7.1 virtualenv name:test nginx uwsgi
假设 项目文件夹位于 /data/www/ts 设置保存在 ./conf
django+uwsgi的部署实在是太蛋疼了..网上已有的教程似乎有新版本的兼容问题。最后跑到uwsgi官网上找的教程终于跑通了..
不过官网的教程似乎有引导教学性质,部署的时候就显得很绕弯路,在这里记录下来精简内容
首先,需要一个uwsgi_params文件,放在项目的conf文件夹里面。之后需要指向它。文件内容如下:
创建一个叫做ts_nginx.conf 的文件,内容如下
# the upstream component nginx needs to connect to
upstream django {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name .example.com; # substitute your machine's ip address or fqdn
charset utf-8;
# max upload size
client_max_body_size 75m; # adjust to taste
# django media
location /media {
alias /data/www/ts/media; # your django project's media files - amend as required
}
location /static {
alias /data/www/ts/static; # your django project's static files - amend as required
}
# finally, send all non-media requests to the django server.
location / {
uwsgi_pass django;
include /data/www/ts/conf/uwsgi_params; # the uwsgi_params file you installed
}
}
把这个conf文件连接到nginx的搜索目录里面。
先决条件:这里要设置好django项目的settings里面static files
python manage.py collectstatic
之后:
应该就可以看到
了(事先放进去一个静态文件)
之后的blabla步骤都是废话,跳到这里:
ts_uwsgi.ini 在项目根目录
这里环境变量设置env需要conf文件夹有init.py,否则conf不会被认为是module
(目前除了80端口,其他端口都可以通过地址:端口访问。已经测试8000,81.80测试不知道为什么不成。明天待续)
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Python 实现将numpy中的nan和inf,nan替换成对应的均值
python爬虫把url链接编码成gbk2312格式过程解析
网友评论