Django Mezzanine uwsgi nginx 配置
1, mezzanine介绍
mezzanine就是一个基于Django框架的应用, 详细可以参考官方网站:http://mezzanine.jupo.org/
2, Mezzanine 安装指南:
# Install from PyPI $ pip install mezzanine # Create a project $ mezzanine-project myproject $ cd myproject # Create a database $ python manage.py createdb # Run the web server $ python manage.py runserver
新建的项目如果要修改主题可以参考:https://github.com/renyi/mezzanine-themes.git
3,修改 nginx的配置文件
到你的 nginx 安装目录下的 conf目录下 修改配置文件 nginx.conf.
**** 关于部署由于之前静态文件的设置问题
cd /usr/local/nginx/conf/ gedit nginx.conf
添加如下内容:
注意 修改你对应项目的路径 比如 alias /home/daniel/myblog/static;
server { listen 8080; server_name 123456; location / { root /home/daniel/myblog/; uwsgi_pass 127.0.0.1:8000; include uwsgi_params; } location /static { autoindex on; alias /home/daniel/myblog/static; access_log off; log_not_found off; } location /robots.txt { alias /home/daniel/myblog/static; access_log off; log_not_found off; } location /favicon.ico { alias /home/daniel/myblog/static/img; access_log off; log_not_found off; } }
至于部署方式可以采用,uWSGI,http://projects.unbit.it/downloads/。
tar zxvf uwsgi-latest.tar.gz cd uwsgi-1.2.6 make cp uwsgi /usr/sbin/uwsgi
安装完uWSGI。
在你的工程目录下新建文件 django_wsgi.py
添加如下内容:
#!/usr/bin/env python # coding: utf-8 import os,sys if not os.path.dirname(__file__) in sys.path[:1]: sys.path.insert(0, os.path.dirname(__file__)) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from django.core.handlers.wsgi import WSGIHandler application = WSGIHandler()
新建文件django.xml
添加如下内容,注意修改为自己的路径:
<uwsgi> <socket>127.0.0.1:8000</socket> <master>true</master> <chdir>/home/daniel/myblog</chdir> <pythonpath>..</pythonpath> <wsgi-file>django_wsgi.py</wsgi-file> <enable-threads>true</enable-threads> </uwsgi>
最后运行: wsgi -x wsgi.xml
这是 配置好了,在浏览器输入: http://localhost:8080/
是不是能够浏览你的站点了。
具体配置可参见我的工程里的相关配置
https://github.com/ustcdane/Mezzanine-uwsgi-nginx
文章转自: http://blog.csdn.net/daniel_ustc/article/details/8855303