下载系统各种依赖

nano /etc/apt/sources.list

在Debian中使用apt-get安装软件包时经常会提示让你插入netinst的光盘:

Media change: please insert the disc labeled

把下面这一行注释掉

deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ - Official amd64 CD Binary-1 20150$

apt-get update

apt-get install python-setuptools python-dev python-pip python-virtualenv redis-server mysql-server mysql-client git -y

把项目拉到服务器

cd ~

ssh-keygen -t rsa

cat ~/.ssh/id_rsa.pub

把公钥粘贴到码云上

git clone xxxxxxxxx

此处应以码云上的地址为准

pip安装各种包

cd ~/serve/

EnvironmentError:mysql config not found

apt-get install libmysqld-dev

网上有人解释说使用apt-get安装的MySQL是没有mysql_config这个文件的

pip install -r requirements.txt

配置celery

cd /etc/systemd/system/

nano celery.service

内容如下:

[Unit]

Description=Celery Service

After=network.target

[Service]

Type=forking

#User=celery

#Group=celery

EnvironmentFile=-/etc/conf.d/celery

WorkingDirectory=/root/serve

ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \

-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \

--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'

ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} \

--pidfile=${CELERYD_PID_FILE}'

ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \

-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \

--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'

[Install]

WantedBy=multi-user.target

mkdir conf.d

cd conf.d/

nano celery

内容如下:

CELERYD_NODES="w1 w2 w3"

CELERY_BIN="/usr/local/bin/celery"

CELERY_APP="serve"

CELERYD_MULTI="multi"

CELERYD_PID_FILE="/etc/celery/%n.pid"

CELERYD_LOG_FILE="/etc/celery/%n%I.log"

CELERYD_LOG_LEVEL=“INFO”

启动celery

systemctl daemon-reload

systemctl start celery

ps -ef|grep celery

systemctl enable celery

systemctl stop celery

安装配置uwsgi

pip install uwsgi

cd /root/

nano serve.ini

内容如下:

[Install]

WantedBy=multi-user.target

root@Aaron:/etc/apt# nano /etc/conf.d/celery

root@Aaron:/etc/apt# cat /root/serve.ini

[uwsgi]

chdir=/root/serve

socket=/var/run/serve.sock

chmod-socket=666

module=serve.wsgi:application

master=True

pidfile=/tmp/serve.pid

vacuum=True

max-requests=5000

processes = 4

daemonize=/var/log/uwsgi/serve.log

测试uwsgi是否正常

uwsgi -i /root/serve.ini

ps -ef |grep uwsgi

pkill -9 uwsgi

安装配置nginx

apt-get install nginx

cd  /etc/nginx/sites-enabled/

nano court

注意要把server_name的ip地址改了

内容如下:

server {

listen          80;

server_name    172.16.146.133;

client_max_body_size    10m;

gzip_vary on;

gzip_proxied any;

gzip_comp_level 6;

gzip_buffers 16 8k;

gzip_http_version 1.1;

gzip_types text/plain text/css application/json application/x-javascript;

location / {

uwsgi_pass      unix:///var/run/serve.sock;

include         uwsgi_params;

uwsgi_param     UWSGI_SCHEME $scheme;

uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;

}

location /static/ {

alias           /root/serve/static/;

index           index.html index.htm;

}

location /static/admin/ {

alias           /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin$

index           index.html index.htm;

}

charset  utf-8;

}

systemctl restart nginx

ps -ef|grep nginx

卸载nginx(if necessary)

dpkg --get-selections|grep nginx

apt-get --purge remove nginx

apt-get --purge remove nginx-common

apt-get --purge remove nginx-core

find / -name "*nginx*"|rm -fr

数据库相关操作

service mysql start

mysql -u root -p

create database serve;

create user ‘serve'@'localhost' identified by ‘serve';

grant all privileges ON serve.* to ‘serve'@'localhost';

flush privileges;

exit;

在django生成数据库相关表

cd ~/serve/

python manage.py makemigrations

python manage.py migrate

python manage.py createsuperuser

启动服务

systemctl start celery

uwsgi -i /root/serve.ini

可能出现的问题

输入ip地址之后,可能样式会丢失,网上解决办法:

chmod -R 755 /root

这个方法个人觉得是有危险的,但是是最快解决问题的,没办法,谁叫你把项目放在root的家目录下

Debian+Django+uWsgi+nginx+mysql+celery的更多相关文章

  1. Linux 集群概念 , wsgi , Nginx负载均衡实验 , 部署CRM(Django+uwsgi+nginx), 部署学城项目(vue+uwsgi+nginx)

    Linux 集群概念 , wsgi , Nginx负载均衡实验 , 部署CRM(Django+uwsgi+nginx), 部署学城项目(vue+uwsgi+nginx) 一丶集群和Nginx反向代理 ...

  2. Django+uWSGI+Nginx 部署网站

    Django 1.11设置 保证Django在本地调试没有问题: 当然这是前提^_^ 收集静态文件至指定文件夹 Django静态文件设置具体参考:https://docs.djangoproject. ...

  3. django+uWSGI+nginx的工作原理流程与部署过程

    django+uWSGI+nginx的工作原理流程与部署过程 一.前言 知识的分享,不应该只是展示出来,还应该解释这样做是为什么... 献给和我一样懵懂中不断汲取知识,进步的人们. 授人与鱼,不如授人 ...

  4. CentOS7.4部署Python3+Django+uWSGI+Nginx

    CentOS7.4部署Python3+Django+uWSGI+Nginx http://www.showerlee.com/archives/2590

  5. virtualvenv+django+uWSGI+nginx 部署

    原创博文 转载请注明出处! 1. virtualvenv 2. django 3. uWSGI 4. nginx 5. 踩坑记录 1. virtualvenv virtualvenv install ...

  6. Django+uwsgi+nginx+angular.js项目部署

    这次部署的前后端分离的项目: 前端采用angular.js,后端采用Django(restframework),他俩之间主要以json数据作为交互 Django+uwsgi的配置可以参考我之前的博客: ...

  7. django+uwsgi+nginx部署(非常详细)

    django+uwsgi+nginx部署 1.介绍: 在网上看了很多教程,但自己部署了很久都没有成功,这篇博文记录自己所踩过得坑. 2.环境: Ubuntu 16.04.1 LTS (GNU/Linu ...

  8. python django uwsgi nginx安装

    python django uwsgi nginx安装 已安装完成python/django的情况下安装 pip install uwsgi cd /usr/share/nginx/html/ vim ...

  9. 10: Django + Uwsgi + Nginx 的生产环境部署

    1.1 一些重要概念 1.Web协议介绍 Web协议出现顺序: CGI -> FCGI -> WSGI -> uwsgi 1. CGI:  最早的协议 2. FCGI:  比CGI快 ...

随机推荐

  1. M-BM-

    今天拷贝了一段代码 struct    Test       {               Test(    int    )    {}               Test()    {}    ...

  2. posgreSQL安装失败解决方案

    选择适合自己电脑版本的postgreSQL进行安装,显示安装失败,错误信息:problem running post-install step.installation may not complet ...

  3. Linux核心命令使用方法

    一.Linux命令行常用快捷键 ctrl + c cancel 取消当前的操作 ctrl + l (小写字母L) clear(命令)清空当前屏幕 ctrl + d 退出当前用户 ctrl + r 查找 ...

  4. linux 单用户密码修改

    1.启动系统,并在GRUB2启动屏显时,按下e键进入编辑模式. 2.在linux16/inux/linuxef所在参数行ro更改为init=/sysroot/bin/sh 3.按Crl+x启动到she ...

  5. SQL Server 中字段的精度问题

    在工作中遇到,一个多表联合查询的情况,查询出来的有些字段精度太高,小数点后达到8个0,现在客户要求报表只要精确到0.01 ,就是只要小数点后面只要保存两位,另外还需要四舍五入 在网上找了点资料,自己测 ...

  6. 【优秀的图片后期编辑工具】Luminar 3.1 for Mac

     [简介] 今天和大家分享最新的 Luminar for Mac 3.1 版本,支持中文界面,Luminar是一款Mac上优秀的图片后期处理工具,功能类似 Photoshop Lightroom 等软 ...

  7. Python正则表达式指南(转)

    目录 Python正则表达式指南(转) 0.防走丢 1. 正则表达式基础 1.1. 简单介绍 1.2. 数量词的贪婪模式与非贪婪模式 1.3. 反斜杠的困扰 1.4. 匹配模式 2. re模块 2.1 ...

  8. 浅入深出Vue系列

    浅入深出Vue导航 导航帖,直接点击标题即可. 文中所有涉及到的资源链接均在最下方列举出来了. 前言 基础篇 浅入深出Vue:工具准备之WebStorm搭建及配置 浅入深出Vue之工具准备(二):Po ...

  9. 【1】学习C++时,一些零散知识点01

    1.编程理念 学习从学习完C后,接触了C++,最重要的便是编程理念的转变.C缩重视的是结构化编程,面对一个较大的程序,就将他分解成小型.便于管理的任务,如果分解后的任务还是偏难过大的话,那将这个任务继 ...

  10. Python爬虫之12306-买票器小白源码

    研究不易 import requests import re import urllib.parse import json import datetime from collections impo ...