開始之前瞭解一下Mezzanine是什麼:
Mezzanine is a powerful, consistent, and flexible content management platform. Built using the Django framework, Mezzanine provides a simple
yet highly extensible architecture that encourages diving in and hacking on the code. Mezzanine is BSD licensed and supported
by a diverse and active community.
In some ways, Mezzanine resembles tools such as WordPress that provide an intuitive interface for managing pages, blog posts, form data, store
products, and other types of content. But Mezzanine is also different. Unlike many other platforms that make extensive use of modules or reusable applications, Mezzanine provides most of its functionality by default. This approach yields a more integrated
and efficient platform.
這也就是官方的簡介,簡單地說Mezzanine就是一個基於Django架構的應用,同時他提供了類似於wordpress的功能。換句話說,Mezzanine就是一個wordpress,我們只需要簡單的修改就可以部署了。一個新項目建立時的,
我們可以看到Mezzanine用作商業的時候是如此的簡單明了。
詳細可以參考官方網站:http://mezzanine.jupo.org/
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
這也就完成了本地開發的第一部。我們可以發現,建立的項目裡面我們很難修改主題,如下所示
3240./static/media/uploads/gallery3244./static/media/uploads3248./static/media3252./static24./deploy8./requirements12./templates3520.
可以使用
python manage.py collecttemplates --help
收集templates
因而,我們需要另外的檔案,也就是templates,這個沒有在需要額外配置。
git clone https://github.com/renyi/mezzanine-themes.git
然後複製目錄中的mazzanine_themes/mazzanine_default到templates中,這樣就可以修改預設的樣式了。
關於部署由於之前靜態檔案的設定問題,因此也就貼了出來。換句話說,預設的靜態檔案和Django一樣需要修改網站nginx的設定檔,比如我的是www.phodal.com.conf。
location /static {autoindex on;alias /home/gmszone/Phodal/static;access_log off;log_not_found off;}location /robots.txtalias /home/gmszone/Phodal/static;access_log off;log_not_found off;}location /favicon.ico {alias /home/gmszone/Phodal/static/img;access_log off;log_not_found off;}
也就是要由nginx指定static的位置,也就沒有那麼多,只需要。記得重啟一下nginx
alias /home/gmszone/Phodal/static;
至於部署方式可以採用,uWSGI。
安裝完uWSGI需要,兩個檔案以便使之運作。
import os,sysif 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 WSGIHandlerapplication = WSGIHandler()
也就wsgi.py,以及
<uwsgi> <socket>127.0.0.1:8630</socket> <chdir>/home/gmszone/Phodal</chdir> <pythonpath>..</pythonpath> <module>wsgi</module></uwsgi>
最後再運行,
uwsgi -x /home/gmszone/Phodal/wsgi.xml
詳細可以參照:http://projects.unbit.it/uwsgi/wiki/Example