# 安装数据库和web服务器nginx

# yum install –y nginx mariadb-server

# 安装虚拟环境

pip install virtualenv
pip install virtualenvwrapper

# 在bashrc中加入如下环境变量

[root@node5 ~]# cat ~/.bashrc
# .bashrc # User specific aliases and functions alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i' # Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/workspace
source /usr/bin/virtualenvwrapper.sh [root@node5 ~]# source ~/.bashrc
# 创建虚拟环境mxonline
[root@node5 ~]# mkvirtualenv mxonline

# 在开发环境中导出我们的依赖环境列表

C:\WINDOWS\system32>workon mxonline

(mxonline) C:\Windows\System32>pip list

将文件导出到requirement.txt中

(mxonline) C:\Windows\System32>pip freeze > requirement.txt

将requirement.txt拷贝到线上,运行批量安装

(mxonline) [root@node5 ~]# pip install -r requirement.txt

中途安装有报错:

yum install python-devel mysql-devel

# 安装uwsgi

(mxonline) [root@node5 ~]# pip install uwsgi

Mysql > create database mxonline;

# 试着启动
(mxonline) [root@node5 mxonline]# python manage.py runserver
Performing system checks... /root/.virtualenvs/mxonline/lib/python2./site-packages/DjangoUeditor/urls.py:: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
url(r'^controller/$',get_ueditor_controller) System check identified no issues ( silenced). You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them. November , - ::
Django version 1.9., using settings 'mxonline.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

把windows开发环境中的数据传输到模拟生产的数据库中

修改监听端口重新运行

(mxonline) [root@node5 mxonline]# python manage.py runserver 0.0.0.0:8000

使用uwsgi程序启动django程序

(mxonline) [root@node5 mxonline]# uwsgi --http :8000 --module mxonline.wsgi

# 修改settings.py文件

# 把这段注释掉

#STATICFILES_DIRS = [

#    os.path.join(BASE_DIR, "static")

#]

# 添加static_root

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

(mxonline) [root@node5 mxonline]# python manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings: /data/www/vhosts/mxonline/static This will overwrite existing files!
Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel: yes
Copying '/root/.virtualenvs/mxonline/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/calendar.js'
Copying '/root/.virtualenvs/mxonline/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/core.js'
Copying '/root/.virtualenvs/mxonline/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/actions.min.js'
Copying '/root/.virtualenvs/mxonline/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/collapse.js'
Copying '/root/.virtualenvs/mxonline/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/timeparse.js'
Copying '/root/.virtualenvs/mxonline/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/actions.js'
Copying '/root/.virtualenvs/mxonline/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/prepopulate.min.js'

# 编辑uwsgi.ini启动文件

(mxonline) [root@node5 conf]# cat /data/www/vhosts/mxonline/conf/uwsgi.ini
# mysite_uwsgi.ini file
[uwsgi] # Django-related settings
# the base directory (full path)
chdir = /data/www/vhosts/mxonline
# Django's wsgi file
module = mxonline.wsgi
# the virtualenv (full path) # process-related settings
# master
master = true
# maximum number of worker processes
processes =
# the socket (use the full path to be safe
socket = 127.0.0.1:
# ... with appropriate permissions - may be needed
# chmod-socket =
# clear environment on exit
vacuum = true
virtualenv = /root/.virtualenvs/mxonline logto = /tmp/mylog.log

# 启动uwsgi 后台运行

# uwsgi -i uwsgi.ini &

此时绑定hosts再次访问80端口就可以访问了

10.10.11.215 www.mxonline.com

# 启动了10个进程

# 自动重启uwsgi

pkill –f uwsgi

会自动重启uwsgi程序

Setgings.py中关闭debug

Debug = False

django在centos生产环境的部署的更多相关文章

  1. 如何一步步在生产环境上部署django和vue

    本文由云+社区发表 本文主要讲述了如何一步步在生产环境上部署django和vue,操作系统默认为centos 说明:后文中出现的以下字符串均表示具体的路径或者名称,含义如下: DJANGO_DIR-- ...

  2. Tomcat学习总结(8)——Tomcat+Nginx集群解决均衡负载及生产环境热部署

    近日,为解决生产环境热部署问题,决定在服务器中增加一个tomcat组成集群,利用集群解决热部署问题. 这样既能解决高并发瓶颈问题,又能解决热部署(不影响用户使用的情况下平滑更新生产服务器)问题. 因为 ...

  3. 配置Django框架为生产环境的注意事项(DEBUG=False)

    问题描述: Django1.10版本中框架中settings.py配置文件 配置文件settings.py配置了下面两项: DEBUG= False ALLOWED_HOSTS = ['*'] #这样 ...

  4. 数据仓库006 - MySQL 5.6.x - Linux最佳生产环境离线部署

    一.离线安装包 文件准备 这里以mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz为例,记一次MySQL 5.6.x 的生产环境离线部署过程.使用SecureCRT连接 ...

  5. 【简书】在阿里云自带的CentOS + LAMP环境下部署一个Laravel项目

    在阿里云自带的CentOS + LAMP环境下部署一个Laravel项目 作者 DonnieZero 关注 2017.07.29 22:02* 字数 2218 阅读 5556评论 3喜欢 1赞赏 1 ...

  6. hadoop进阶----hadoop经验(一)-----生产环境hadoop部署在超大内存服务器的虚拟机集群上vs几个内存较小的物理机

    生产环境 hadoop部署在超大内存服务器的虚拟机集群上 好 还是  几个内存较小的物理机上好? 虚拟机集群优点 虚拟化会带来一些其他方面的功能. 资源隔离.有些集群是专用的,比如给你三台设备只跑一个 ...

  7. Django+Nginx+uWSGI生产环境部署

    生产环境中的数据流 参考文档: wsgi详解:https://blog.csdn.net/li_101357/article/details/52748323 wsgi协议介绍(萌新版):https: ...

  8. 学习项目部署Django+uwsgi+Nginx生产环境部署

    绪论 项目生产环境部署,是很重的一个知识点.第一,Django自带的服务器很简陋,由于测试和开发环境尚可,无法用于生产环境,保障安全性和可靠性.以及性能.此外,学习部署方式,还有利于了解生产部署后的项 ...

  9. django生产环境中部署

    https://www.cnblogs.com/chenice/p/6921727.html 本节内容 uwsgi 介绍 uwsgi安装使用 nginx安装配置 django with nginx 如 ...

随机推荐

  1. 【Nginx】将http升级到https并且同时支持http和https两种请求

    一.如何将http升级到https 需要满足下面三个: 1.域名 2.nginx 3.SSL证书     一般第三方证书颁发机构下发的证书是收费的,一年好几千.    1) 从腾讯云申请免费的SSL证 ...

  2. Python卸载不干净?苹果电脑卸载python教程

    如今,Pyhon越来越火,屡次超越Java.C++成为编程语言排行榜第一的语言,国内的公司和程序员们也越来越喜欢使用Python.但是Python安装之后,散落在电脑各处,删除起来比较麻烦,很多小伙伴 ...

  3. DFS 算法模板

    dfs算法模板: 1.下一层是多节点的dfs遍历 def dfs(array or root, cur_layer, path, result): if cur_layer == len(array) ...

  4. Java精通并发-Lock与synchronized关键字在底层的区别及实例分析

    在上两次中已经将Lock这个接口的整个官方说明进行了阅读,这次来了解一下它的一个非常重要的实现类: 啥叫“可重入”呢?其实是指一个线程已经拿到了锁,然后该线程还能再次获取这把锁,接下来在了解它之前先用 ...

  5. Python基础笔记-元祖

    Python 的元组与列表类似,不同之处在于元组的元素不能修改. 元组使用小括号,列表使用方括号. 元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可. def main(): tup2 = ...

  6. Object archiving

    https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/Arch ...

  7. swift函数式编程之compose

    func a(en:String) -> String { return en + "a"; } func b(en:String) -> String { retur ...

  8. Mysql命令下导出select查询数据之 select ... into outfile方法

    Mysql日常使用中经常遇到将select查询的数据导出到本地目录的情况,以便数据备份.分析等. 接下来将介绍Mysql终端下使用 select ... into outfile 语句导出数据方法 命 ...

  9. 24 Home Assistant

    Home Assistant https://github.com/home-assistant/home-assistant python3 -m pip install homeassistant ...

  10. Presto Infrastructure at Lyft

    转载一篇关于 lyft presto 平台建设的实践 Overview Early in 2017 we started exploring Presto for OLAP use cases and ...