博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[django]django+nginx+gunicorn+mysql
阅读量:4228 次
发布时间:2019-05-26

本文共 2511 字,大约阅读时间需要 8 分钟。

#NOTE:

command start with "***(show_buiding)*** ", means run in virtualenv

#安装mysql

参考:

#安装virtualenv,用来配置多环境

参考:

#在新环境中安装django

//bz I'm using python2.7 so install the old django//(show_buiding) $ python -m pip install "django<2" 装2以下(show_buiding) $ python -m pip install django //装2,准备在python3环境运行, 一定要注意,如果当前是python2直接这么装有问题,需要用python3装,也就是要切换虚拟环境//create new project(show_buiding) $ django-admin startproject show_building//run and check the server(show_buiding) $ python manage.py runserver 0.0.0.0:80//if want to add domain, then need to update the settings.py(show_buiding) $ cd show_building/show_building(show_buiding) $ vim settings.y
//add hostALLOWED_HOSTS = ['www.xxx.com'		,'xxx.com' 		]//save and restart, it should be working.

#Link to mysql

##install mysql-python
NOTE: if meet issue,

(show_buiding) pip install mysql-python //刚试了下,出问题了,以后再改

##add config to

(show_buiding) $ vim settings.py
DATABASES = {    'default': {        'ENGINE': 'django.db.backends.mysql',        'NAME': 'show_building',		'USER':'xxx',		'PASSWORD':'xxx',		'HOST':'localhost',		'PORT':'',    }}
//migrate//python manage.py syncdb <- departure(show_buiding) $ ./manage.py migrate//then restart server again

untill now, the server is running.

#install gunicorn

(show_buiding) $ pip install gunicorn//at the same level of manage.py$ gunicorn show_building.wsgi:application --bind 0.0.0.0:8800 &//NOTE:: if the **8800** port can be accessed from outside, then you can open the web page like : http://www.xxx.com:8800

#Nginx

##install

$ sudo apt-get install nginx

##Config

$ vim /etc/nginx/sites-available/default
server {    listen   80;    server_name xxable.com www.xxable.com fkdev.com www.fkdev.com;    client_max_body_size 4G;    access_log /root/web/show_buiding/show_building/logs/nginx-access.log;    error_log /root/web/show_buiding/show_building/logs/nginx-error.log;    location /static/ {        alias   /root/web/show_buiding/show_building/static/;    }    location /media/ {        alias   /root/web/show_buiding/show_building/media/;    }    location / { 	proxy_pass http://127.0.0.1:8800;       proxy_set_header X-Real-IP $remote_addr;         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;        proxy_set_header Host $http_host;        proxy_redirect off;            }    # Error pages    error_page 500 502 503 504 /500.html;    location = /500.html {        root /root/web/show_buiding/show_building/static/;    }}

##start

$sudo  service nginx start

Untill now the server is running !!!

转载地址:http://bdcqi.baihongyu.com/

你可能感兴趣的文章
对.lds连接脚本文件的分析
查看>>
通过内核源码看函数调用之前世今生(转载)
查看>>
你的变量究竟存储在什么地方?
查看>>
s3c2410 中断异常处理(转)
查看>>
对张孝祥C语言试题其中一题的探讨 (转载)
查看>>
一些好的网站
查看>>
map.txt
查看>>
volatile关键字
查看>>
ZLG7290键盘驱动开发心得
查看>>
WinCE中的虚拟地址和实际的物理地址是如何对应
查看>>
Microsoft Windows CE 的内存使用
查看>>
makefile入门
查看>>
中科院计算所Goddon CPU诞生历史!牛!
查看>>
ispPAC
查看>>
迷你型的 Linux 系统
查看>>
为人处世小技巧
查看>>
C++ 堆、栈及静态数据区详解
查看>>
VC++6.0编译环境介绍
查看>>
74芯片特性分类使总汇
查看>>
ttl和cmos的区别
查看>>