Debian+Django+uWsgi+nginx+mysql+celery
下载系统各种依赖
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的更多相关文章
- Linux 集群概念 , wsgi , Nginx负载均衡实验 , 部署CRM(Django+uwsgi+nginx), 部署学城项目(vue+uwsgi+nginx)
Linux 集群概念 , wsgi , Nginx负载均衡实验 , 部署CRM(Django+uwsgi+nginx), 部署学城项目(vue+uwsgi+nginx) 一丶集群和Nginx反向代理 ...
- Django+uWSGI+Nginx 部署网站
Django 1.11设置 保证Django在本地调试没有问题: 当然这是前提^_^ 收集静态文件至指定文件夹 Django静态文件设置具体参考:https://docs.djangoproject. ...
- django+uWSGI+nginx的工作原理流程与部署过程
django+uWSGI+nginx的工作原理流程与部署过程 一.前言 知识的分享,不应该只是展示出来,还应该解释这样做是为什么... 献给和我一样懵懂中不断汲取知识,进步的人们. 授人与鱼,不如授人 ...
- CentOS7.4部署Python3+Django+uWSGI+Nginx
CentOS7.4部署Python3+Django+uWSGI+Nginx http://www.showerlee.com/archives/2590
- virtualvenv+django+uWSGI+nginx 部署
原创博文 转载请注明出处! 1. virtualvenv 2. django 3. uWSGI 4. nginx 5. 踩坑记录 1. virtualvenv virtualvenv install ...
- Django+uwsgi+nginx+angular.js项目部署
这次部署的前后端分离的项目: 前端采用angular.js,后端采用Django(restframework),他俩之间主要以json数据作为交互 Django+uwsgi的配置可以参考我之前的博客: ...
- django+uwsgi+nginx部署(非常详细)
django+uwsgi+nginx部署 1.介绍: 在网上看了很多教程,但自己部署了很久都没有成功,这篇博文记录自己所踩过得坑. 2.环境: Ubuntu 16.04.1 LTS (GNU/Linu ...
- python django uwsgi nginx安装
python django uwsgi nginx安装 已安装完成python/django的情况下安装 pip install uwsgi cd /usr/share/nginx/html/ vim ...
- 10: Django + Uwsgi + Nginx 的生产环境部署
1.1 一些重要概念 1.Web协议介绍 Web协议出现顺序: CGI -> FCGI -> WSGI -> uwsgi 1. CGI: 最早的协议 2. FCGI: 比CGI快 ...
随机推荐
- MySQL逻辑备份mysqldump
MySQL 备份之 mysqldump mysqldump mysqldump工具备份: 本质:导出的是SQL语句文件 优点:不论是什么存储引擎,都可以用mysqldump备成SQL语句 缺点:速度较 ...
- 指路Reactive Programming
指路Reactive Programming Mar 02, 2016 in Engineering 我在工作中采用Reactive Programming(RP)已经有一年了,对于这个“新鲜”的辞藻 ...
- Asp.net MVC 权限过滤器实现方法的最佳实践
在项目开发中,为了安全.方便地判断用户是否有访问当前资源(Action)的权限,我们一般通过全局过滤器来实现. Asp.net MVC 页面中常见的权限判断使用过滤器主要在以下几种情况(根据权限判断的 ...
- JWT 加密
什么是JWT Json web token (JWT), 是为了在网络应用环境间传递声明而执行的一种基于JSON的开放标准((RFC 7519).该token被设计为紧凑且安全的,特别适用于分布式站点 ...
- C# Linq to Entity 多条件 OR查询
技术背景:框架MVC,linq to Entity 需要一定的lambda书写能力 问题:在简单的orm中完成一些简单的增删查改是通过where insert delete update 完成的,但是 ...
- macbook配置xdebug+vscode
1.从xdebug官网下载xdebug 地址:https://xdebug.org/index.php,如果你不知道你要下载哪个版本的话可以下载它建议的版本.使用方法是在 https://xdebug ...
- IDEA2019激活码集合(非盈利)
56ZS5PQ1RF-eyJsaWNlbnNlSWQiOiI1NlpTNVBRMVJGIiwibGljZW5zZWVOYW1lIjoi5q2j54mI5o6I5p2DIC4iLCJhc3NpZ25lZ ...
- luogu P5324 [BJOI2019]删数
传送门 不如先考虑暴力,能删的序列首先有\(1,2,3...n\),还有就是升序排序后从后往前放数,第\(i\)位要么放\(i\),要么放\(i+1\)位置的数,例如\(1,2,4,4,5,6,9,9 ...
- Codeforces Round #552 (Div. 3) F. Shovels Shop(dp)
题目链接 大意:给你n个物品和m种优惠方式,让你买k种,问最少多少钱. 思路:考虑dpdpdp,dp[x]dp[x]dp[x]表示买xxx种物品的最少花费,然后遍历mmm种优惠方式就行转移就好了. # ...
- vue内置的标签(组件)
component:用于动态组件,查看博文vue学习之组件. <component :is="componentId"></component> trans ...