django Mezzanine uwsgi nginx 配置

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.