>  기사  >  백엔드 개발  >  Django 메자닌 uwsgi nginx 配置

Django 메자닌 uwsgi nginx 配置

高洛峰
高洛峰원래의
2016-10-17 13:52:461264검색

1. 메자닌 소개

메자닌은 Django 프레임워크 기반 애플리케이션입니다. 자세한 내용은 공식 홈페이지(http://mezzanine.jupo.org/

를 참조하세요. 2. 메자닌 설치 가이드 :

# 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()

새로 만들기 file 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


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.