【系统运维】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;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章