【系统运维】ubuntu 14.04部署python项目(Nginx+uwsgi+django)

当我们想在公众号中添加特别的功能,比如说聊天机器人、消息推送等,都会用到公众号提供的开发者工具,下面截图是提供的部分基础功能,那需要准备些什么呢​?

创建用户

http://blog.csdn.net/kuaisuzhuceh/article/details/44681249

ubuntu新建用户不能使用ll等指令,显示出来的信息没有颜色区分的解决方案

http://www.lxway.com/46248022.htm

添加 sudo

https://www.linuxidc.com/Linux/2016-07/133066.htm

sudo apt-get update

http://blog.csdn.net/xiaogugood/article/details/18400669

ubuntu 16.04部署python项目(Nginx+uwsgi+django)

https://www.cnblogs.com/zhoufankui/p/7967499.html

Django + Uwsgi + Nginx 实现生产环境部署

Python- 解决PIP下载安装速度慢

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple

安装SVN

sudo apt-get install subversion

MySQL

安装python-dev
sudo apt-get install python-dev
然后再安装
sudo apt-get install libmysqlclient-dev

报错gcc编译,其实是解决编译过程找不到对应库文件

一般出现这种错误有以下几种原因:
1.系统缺乏对应的库文件;
2.版本不对应;
3.库文件的链接错误;
4.库文件路径设置问题。

    /usr/bin/ld: cannot find -lssl
    /usr/bin/ld: cannot find -lcrypto
    collect2: error: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1

    /usr/bin/ld: cannot find -lssl
    /usr/bin/ld: cannot find -lcrypto
    collect2: error: ld returned 1 exit status
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
解决方法

apt-get install libxxx-dev
命名方式 ‘lib’+库名(即xxx)+’-dev’

示例
/usr/bin/ld: cannot find -lssl   就是   apt-get install libssl-dev
最后安装

pip install MySQL-python

SqlServer

sudo apt-get install unixodbc-dev
pip install pyodbc4.0.21
pip install django-pyodbc
1.1.3

Oracle

pip install cx_oracle

收集静态文件夹中的所有Django静态文件

STATIC_ROOT = os.path.join(BASE_DIR, “static/”)
python manage.py collectstatic

/home/laowang/project/canyou/

ps ax | grep uwsgi
uwsgi --ini uwsgi.ini

[uwsgi]
# uwsig使用配置文件启动
http = :8090
# 项目目录
chdir = /home/laowang/project/canyou
# 指定项目的application
module = canyou.wsgi
# 指定sock的文件路径
socket=/home/laowang/project/canyou/uwsgi.sock
# 启动uwsgi的用户名和用户组
uid=root
gid=root
# 进程个数
workers=100
pidfile=/home/laowang/project/canyou/uwsgi.pid
# 启用主进程
master=true
# 自动移除unix Socket和pid文件当服务停止的时候
vacuum=true
# 序列化接受的内容,如果可能的话
thunder-lock=true
# 启用线程
enable-threads=true
# 设置自中断时间
harakiri=30
# 设置缓冲
post-buffering=4096
# 设置日志目录
daemonize=/home/laowang/project/canyou/uwsgi.log

/etc/nginx

nginx.conf


events {
    worker_connections  65535;
}

http{
    include       mime.types;
    default_type  application/octet-stream;
server {
    # the port your site will be served on
    listen      80;
    # the domain name it will serve for
    charset     utf-8;

    # max upload size
    client_max_body_size 100M;   # adjust to taste

    # Django media
    location /media  {
        alias /home/laowang/project/canyou/media;  # your Django project's media files - amend as required
    }
    # Django upload
    location /upload  {
        alias /home/laowang/project/canyou/upload;  # your Django project's media files - amend as required
    }

    location /static {
        alias /home/laowang/project/canyou/static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        add_header Access-Control-Allow-Origin *;
        proxy_pass http://127.0.0.1:8090;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
}

service nginx restart
service nginx start
service nginx stop

nginx做静态代理时css加载不出问题解决

http://blog.csdn.net/justnow_/article/details/52628022
css 加载失败
include mime.types;
default_type application/octet-stream;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不太灵光的程序员

有用的话可以请博主喝杯咖啡续命

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值