nginx+uwsgi+django(restframework)服务器部署
来源:互联网 发布:乐器软件 编辑:程序博客网 时间:2024/05/19 07:11
django项目假设已完成
安装问题
nginx
pip install nginx
error:package nginxcore is not configured yet
解决:先安装这些缺失的包
还有一种情况版本情况高于该包之类的,也是有些相关包没有预先安装。
uwsgi
pip install uwsgi
error
no request plugin is loaded you will not be able to manage requests
解决:sudo apt-get install uwsgi-plugin-python
supervisor
pip install supervisor
sudo echo_supervisor_conf > /etc/supervisord.conf
配置
nginx.conf
项目服务应写在nginx.conf的http{}中或site-availabled/site-enabled 中的conf文件中
http{... server { listen 8035; #root /usr/share/nginx/html; index index.html index.htm index.nginx-debian.html; client_max_body_size 75M; server_name localhost; charset UTF-8; location /static { add_header Cache-Control private; alias /home/zhouxin/com_tel_query/static/; } location / { include uwsgi_params; uwsgi_pass localhost:8037; uwsgi_read_timeout 2; } }include /etc/nginx/conf.d/*.conf;#include /etc/nginx/sites-enabled/*;... }
web_uwsgi.ini(任意取名,对应好)
[uwsgi]
plugin = python
http=:8037 #socket=:8037需对应到sock,自行延伸
chdir = /home/your/project_name/
module = com_tel_query.wsgi:application #:application必须加
master = true
processes = 4
buffer-size = 32786 #应对error:invalid request block size: 21327 (max 4096)…skip
uwsgi –ini web_uwsgi.ini 测试运行状态
admin/restframework后台css样式缺失
setting.py
STATIC_ROOT = ‘/your/path/to/static_resource/static’#或相对路径
STATIC_URL = ‘static’
cd project
mkdir static
python manage.py collectstatic #自动copy admin和restframework的css/js等文件到static
仍然缺失的情况下可尝试:
urls.py
from django.conf import settings
from django.conf.urls.static import static
urlparrerns = [
your url…
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
守护进程-supervisor
supervisord /etc/supervisor.conf
error:
Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting
解决:
find / -name supervisor.cock #找到sock文件所在目录
unlink path/supervisor.sock
后台服务持续开启:vim /etc/supervisord.conf (可另写conf文件放入相应/usr/local/bin/supervisor文件夹中,supervisord.conf 中include *.conf,可以一个服务一个conf)
在conf最底部加入:
[program:comTel]
directory=/home/zhouxin/com_tel_query #project目录
command=uwsgi –ini /home/zhouxin/com_tel_query/web_uwsgi.ini
user=root #运行的用户名
autostart=true
autorestart=true
loglevel=error
stdout_logfile=/home/zhouxin/com_tel_query/logs/uwsgi_out.log
stderr_logfile=/home/zhouxin/com_tel_query/logs/uwsgi_err.log #logs文件夹要在运行conf前建立
logfile_maxbytes=1M
一些命令
supervisorctl status #查看当前服务状态
supervisorctl reload #重载被修改过的conf文件
supervisorctl -c /etc/spervisord.conf start/stop program-name #启动/关闭
运行
/usr/local/bin/supervisord -c /etc/supervisord.conf #写全supervisord的路径而非直接supervisord 命令
- nginx+uwsgi+django(restframework)服务器部署
- Django+Nginx+uwsgi部署
- nginx uwsgi django部署
- nginx uwsgi 部署django
- django nginx+uwsgi部署
- Django+uWsgi+nginx部署
- Nginx+uWSGI+Django部署
- nginx+uwsgi部署django
- nginx+uwsgi部署django
- nginx+uwsgi 部署django
- Django nginx uwsgi部署
- uwsgi+django+nginx部署
- nginx+uwsgi+django部署
- nginx + uwsgi + django部署
- DJango+UWSgi+Nginx部署
- uwsgi+nginx部署Django
- Django+Nginx+uWSGI部署
- 从零开始在 Ubuntu 下部署 Nginx uWSGI Django 服务器
- 致命错误: 在类路径或引导类路径中找不到程序包 java.lang
- mybatis逆向工程遇到的坑
- LabVIEW密码破解,VI密码重置,VI密码破解神器,labview密码破解
- QGC的第二个按钮Vehicle Setup
- 解决多线程访问全局变量的解决方案
- nginx+uwsgi+django(restframework)服务器部署
- 不要滥用递归
- SHA-1
- h5 input控件 多文件上传
- Java File类的简单说明与使用 -- Java 基础
- iis http重定向https
- Java调优经验谈--转
- SQL执行查询时出现返回数据为空的问题
- 自定义控件 RoundImageView