Django
初次接触Django,大概使用了下发现跟php还是有一些区别的.
Django不像php的大多数框架,其自身已经整合了包括WebServer 管理后台 用户认证等很多的功能;
虽然有了WebServer,但是Django明确规定manage.py runserver{port}
只适合开发使用,发布环境还是需要uwsgi
, 依旧是主流的nginx + fastcgi
下面还是简单记录一下整个环境的安装过程
Django
**安装请参照官方文档
uwsgi
1. 安装 aptitude install uwsgi
2. 创建配置 uwsgi.xml
<uwsgi>
<plugin>python</plugin>
<socket>/etc/nginx/uwsgi.sock</socket>
<chmod-socket>777</chmod-socket>
<pythonpath>/var/www/website</pythonpath>
<app mountpoint="/">
<script>website.wsgi</script>
</app>
<module>website.wsgi</module>
<master>true</master>
<processes>1</processes>
<enable-threads>true</enable-threads>
<logdate>true</logdate>
<harakiri>60</harakiri>
<reload-mercy>8</reload-mercy>
<max-requests>200</max-requests>
<limit-as>512</limit-as>
<reload-on-as>256</reload-on-as>
<reload-on-rss>192</reload-on-rss>
<vacuum/>
<daemonize>/var/log/uwsgi.log</daemonize>
</uwsgi>
3. nginx调用uwsgi
server{
listen 80;
server_name yjiang.wicp.net;
root /var/www/website/;
location / {
include uwsgi_params;
uwsgi_pass unix:/etc/nginx/uwsgi.sock;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
}
}
4. 启动uwsgi
uwsgi -x uwsgi.xml
5. 重启nginx
service nginx restart
关闭
pkill -9 uwsgi