下载系统各种依赖

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. Spring 实现动态数据源切换--转载 (AbstractRoutingDataSource)的使用

    [参考]Spring(AbstractRoutingDataSource)实现动态数据源切换--转载 [参考] 利用Spring的AbstractRoutingDataSource解决多数据源的问题 ...

  2. centos7 部署安装gitlab服务器

    概念: git 是一种版本控制系统,是一个命令,是一种工具 gitlib 是用于实现git功能的开发库 github 是一个基于git实现的在线代码托管仓库,包含一个网站界面,向互联网开放 gitla ...

  3. 转载:Linux命令之查看文件占用空间大小-du,df

    转载自:<du命令>-linux命令五分钟系列之三 du(disk usage),顾名思义,查看目录/文件占用空间大小 #查看当前目录下的所有目录以及子目录的大小$ du -h $ du ...

  4. (转) qt: usb热插拔(linux);

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> ...

  5. 从Random Walk谈到Bacterial foraging optimization algorithm(BFOA),再谈到Ramdom Walk Graph Segmentation图分割算法

    1. 从细菌的趋化性谈起 0x1:物质化学浓度梯度 类似于概率分布中概率密度的概念.在溶液中存在不同的浓度区域. 如放一颗糖在水盆里,糖慢慢溶于水,糖附近的水含糖量比远离糖的水含糖量要高,也就是糖附近 ...

  6. Angular+Ionic+RSA实现后端加密前端解密功能

    因业务需要,需要给android应用安装证书,通过读取证书文件内容实现某些功能的控制: 流程:后台通过publicKey对指定内容的文件进行加密,生成文件共客户下载,客户下载后选择该证书文件读取到应用 ...

  7. Entity Framework系列教程汇总

    翻译自http://www.entityframeworktutorial.net/,使用EF几年时间了,一直没有系统总结过,所以翻译这一系统文章作为总结,由于英语功底有限,翻译的可能有些问题,欢迎指 ...

  8. Kafka(一)简介

    1.Kafka简介 Kafka已经被很多公司广泛应用,一款实时流式消息组件.发送消息端称为Producer,接收端称为Consumer,Kafka集群有多个kafka实例组成,每个实例称为broker ...

  9. 在页面加载前先出现加载loading,页面加载完成之后再显示页面

    在此加入一个关于页面加载成功之前先展现一个loading的案例: 如下代码写入js里放在html头部即可实现需求:添加的可以自己在css文件设置宽高,也可以放入一个background的gif的loa ...

  10. 从XML文件和properties文件提取数据

    XML文档格式内容如下 <?xml version="1.0" encoding="UTF-8"?> <root>     <fi ...