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-8import 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