下载系统各种依赖

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. 微信小程序onLaunch、onLoad执行生命周期

    原文转载自:微信小程序onLaunch.onLoad执行生命周期 1.需求:先执行App的onLaunch添加验证权限等,再执行Page里的onLoad. 2.问题:还没有等onLaunch执行完成, ...

  2. 洛谷P4389 付公主的背包--生成函数+多项式

    题目链接戳这里 题目描述 有\(n\)件不同的商品,每件物品都有无限个,输出总体积为\([1,m]\)的方案数 思路 直接跑背包有\(30\) 考虑把每个物品的生成函数设出来,对于一件体积为\(v\) ...

  3. 关于 redis 的 数据类型 和 内存模型

    该文章 是在读了 公众号 : java 后端技术 之后 做的一个小记录 原文网址  : https://mp.weixin.qq.com/s/mI3nDtQdlVlLv2uUTxJegA 作者文章写的 ...

  4. [BZOJ4318] OSU!

    比较简单,每个键分两种情况计算期望. 然而要注意的是,期望是线性运算,期望的平方不是平方的期望 . #include <cmath> #include <queue> #inc ...

  5. codeforces-1136 (div2)

    A.读到第i章,就有N - i + 1章还没读. #include <map> #include <set> #include <ctime> #include & ...

  6. MapReduce-CombineTextInputFormat 切片机制

    MapReduce 框架默认的 TextInputFormat 切片机制是对任务按文件规划切片,如果有大量小文件,就会产生大量的 MapTask,处理小文件效率非常低. CombineTextInpu ...

  7. Hadoop记录-切换NN

    一.第一种方法 重启namenode(1.1.1.1 1.1.1.2)重启standby节点:1.1hadoop-daemon.sh stop zkfchadoop-daemon.sh stop na ...

  8. HTML界面多语言切换

    我在做个人网站时考虑到多语言转换的问题,最后在JS文件中将所有文字数据储存然后设置HTML中的class与key属性来达到多语言效果.当然,还有一个别的方法,就是所有有文字内容的div都用不同语言写一 ...

  9. C#代码使用Process类调用SWFTools工具

    一.Process类调用SWFTools工具将PDF文档转为swf文档 1 string cmdStr = "D:\\SWFTools\\pdf2swf.exe"; string ...

  10. JSP和后台交互时的乱码问题

    在Servlet或者是拦截器里面添加下面的语句: request.setCharacterEncoding("utf-8"); response.setCharacterEncod ...