【系統運維】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;

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