linux部署django專案流程(全)

2022-05-06 04:12:09 字數 2168 閱讀 9115

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make -y
pip freeze > packet.txt
pip3 install -r packer.txt
systemctl stop firewalld
執行專案觀察是否正常執行

pip3 install uwsgi
建立軟連線

ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi

uwsgi --http 10.10.14.180:80 --file 專案名/wsgi.py --static-map=/static=static
mkdir script

vim uwsgi.ini

[uwsgi]

chdir=/opt/ourblog #專案目錄

socket=/opt/script/uwsgi.sock #指定sock的檔案路徑

workers=5 #程序個數

pidfile=/opt/script/uwsgi.pid

http=192.168.2.69:8000 #指定ip埠

static-map=/static=/opt/ourblog/static #指定靜態檔案

uid=root #使用者

gid=root #組

master=true #啟用主程序

vacuum=true #自動移除unix socket和pid檔案當服務停止的時候

enable-threads=true #啟用執行緒

thunder-lock=true #序列化接受的內容,如果可能的話

harakiri=30 #設定自中斷時間

post-buffering=4096 #設定緩衝

daemonize=/opt/script/uwsgi.log #設定日誌目錄

uwsgi --ini uwsgi.ini

資料夾下多出uwsgi.log,uwsgi.pid,uwsgi.sock三個檔案

wget -c
tar -zxvf nginx...
./configure \

make && make install

ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
nginx
pkill -9 uwsgi

pkill -9 nginx

在/usr/local/nginx/conf目錄下

cp nginx.conf nginx.conf.bak

在/var/log目錄下

access_log  /var/log/nginx/access.log  main; #訪問日誌路徑,注意:這個目錄可能沒有,需要建立

error_log /var/log/nginx/error.log error; #錯誤日誌注意:這個目錄可能沒有,需要建立

location /

location = /static/

修改uwsgi.ini檔案中ip為127.0.0.1:8000
netstat -nltp | grep 80

linux 部署django專案

1.安裝python直譯器 跳轉 2.安裝mysql 跳轉 3.建立資料庫並匯入資料 匯出 mysqldump u root p test test sql 匯入 mysql uroot p test test sql4.建立虛擬環境 跳轉 5.上傳django專案 到linux伺服器 6.解決專案...

Linux下部署Django專案

目錄 安裝python3.x環境 安裝部署開啟django 由於linux系統預設自帶的是2.x環境,所以我們需要去安裝3.x環境的python。wget2 接著解壓這個壓縮包,命令如下 tar xvf python 3.6.3.tar.xz3 接著編譯安裝,進入解壓後的目錄,執行底下的乙個shel...

部署django專案

在你專案的根目錄中建立mysite.xml 名字無所謂 或者建立mysite.ini,輸入以下內容 uwsgi socket 127.0.0.1 8000 socket chdir data project1 chdir module project1.wsgi module processes 4...