python3.6 django部署_部署python3.6下的django

首先是安裝好nginx,配置web目錄,配置文件在confi.d中,

server {

# the port your site will be served on

listen80;

# the domain name it will serveforserver_name localhost; # substitute your machine's IP address or FQDN

charset utf-8;

# max upload size

client_max_body_size 75M; # adjust to taste

# Django media

location/media {

alias/var/www/myweb/media; # your Django project's media files - amend as required

}

location/static{

alias/var/www/myweb/static; # your Django project's static files - amend as required

}

# Finally, send all non-media requests to the Django server.

location/{

include/etc/nginx/uwsgi_params; # the uwsgi_params file you installed

uwsgi_pass127.0.0.1:8001;

}

}

修改nginx配置文件后,需要重新啟動nginx

service nginx restart

把web文件git上傳到/var/www/myweb中去

可以使用pycharm的自動同步代碼工具,自動上傳代碼到服務器,速度特別快。

d759e462b101f028d8aae9d8b403e50b.jpe

在settings.py中有一項wsgi的配置:

786aefb96ed74426fd0a460a512d8184.jpe

服務器端安裝插件

pip install django

pip install mysqlclient

pip install pillow

遷移數據

python manage.py makemigrations

python manage.py migrate

啟動服務

screen -S xyz

uwsgi-s:8001 -w web.wsgi

ctrl +a+d 退出screen

3447af7b6fe7493f84a7f17c57550363.jpe

-----------------------

登陸后台發現沒有樣式了……只好把文件復制進去……

0bd1a1c6e9087f64a8f868eb245b5818.jpe

注意,在第二個Lib文件夾下的文件,復制到根目錄對應的文件夾中,上傳到服務器就好了。之前需要在服務器上創建超級管理員。

283cdd42f14e0b1e770e2d68bf2231eb.jpe

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值