# 安装数据库和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. Django之DRF源码分析(四)---频率认证组件

    核心源码 def check_throttles(self, request): """ Check if request should be throttled. Ra ...

  2. X509Store 类

    标题:X509Store 类 地址:https://docs.microsoft.com/zh-cn/dotnet/api/system.security.cryptography.x509certi ...

  3. PAT 乙级 1007.素数对猜想 C++/Java

    1007 素数对猜想 (20 分) 题目来源 让我们定义d​n​​为:d​n​​=p​n+1​​−p​n​​,其中p​i​​是第i个素数.显然有d​1​​=1,且对于n>1有d​n​​是偶数.“ ...

  4. socks_send(fd,sbuf,strlen(sbuf));

    unix 命名socket发送直接发送  1024字节  计算strlen 计算的字符不正确,截取 无法正常发送

  5. 在github上优雅的搭建个人博客

    前言 啊啊啊---,经过差不多两天的持续摸索优化,个人博客算是初步完成了,现在自己看的效果还是非常不错的.这篇文章就是讲我怎么搭建一个这样的博客的.早在17年的时候就用hexo 结合github搭建过 ...

  6. git 学习记录—— git 中的仓库、文件状态、修改和提交操作等

    最近开始学习使用版本控制工具  git .学习方式主要通过阅读 git 网站上的 Pro git 和动手实践,使用的系统为 Ubuntu16.04LTS,以及 Windows 8.1. 本文主要关注 ...

  7. wordpress调用指定分类除外的置顶文章

    我们有时需要根据实际需要进行一些设置,比如wordpress调用指定分类除外的置顶文章,如何实现呢?随ytkah一起来看看吧,用如下代码插入到需要调取的位置 <div class="r ...

  8. mcp2515屏蔽寄存器和过滤寄存器的学习

    mcp2515是can控制器,简单的来讲,就是只要配置好寄存器,芯片就能够自动的解析can数据帧,同时保存到接收缓存中,提醒单片机可以读取can的数据字节. 读取的方式是快速spi,可以达到10Mbi ...

  9. GPU的主要工作:图像合成、图形操作、光线表达

    GPU的主要工作:图像合成.图形操作 gpu不产生图片, 只表达和处理图片.图形:

  10. 做个小插件(打开Part路径插件)

    1 (CAIDAN.men) VERSION EDIT UG_GATEWAY_MAIN_MENUBAR AFTER UG_HELP CASCADE_BUTTON TOOLS LABEL 工具 END_ ...