Django+vue项目部署

Posted by BUAADreamer on 2021-07-11
Words 451 and Reading Time 2 Minutes
Viewed Times

后端配置·

在Ubuntu/Linux环境下使用MySQL:启动和关闭MySQL服务

1
2
3
service mysql start
service mysql status
service mysql stop

修改.cnf文件的方法:直接 sudo vim my.cnf

mysql my.cnf配置:https://blog.csdn.net/weixin_43633797/article/details/102524499

查看监听端口:netstat -tln https://www.136.la/mysql/show-80993.html

彻底删除并重装mysql:https://www.codenong.com/cs106182111/

sudo apt install mysql-server

sudo apt install libmysqlclient-dev

初始密码找不到进不去:https://blog.csdn.net/r527665047/article/details/107056941/

修改完密码之后要重启mysql!

进入后端根目录

python manage.py makemigrations

python manage.py runserver 8000

https://www.cnblogs.com/steven_oyj/archive/2010/05/24/1742808.html

https://blog.csdn.net/leacock1991/article/details/110406708

解决OSError: mysql_config not found问题:https://blog.csdn.net/zy_whynot/article/details/106960087

mongo远程连接:https://www.cnblogs.com/kimkat/p/9192785.html

ngnix配置·

https://www.cnblogs.com/niehaidong111/p/11208492.html

https://www.cnblogs.com/NAG2020/p/12920154.html

安装ngnix:https://blog.csdn.net/qq_23832313/article/details/83578836

https://www.cnblogs.com/gede/p/11011693.html

sudo vim /etc/nginx/conf.d/istic.conf

前端配置·

安装npm·

sudo apt update

sudo apt install npm

git clone https://gitee.com/muller2020/BUAACrawler.git

进入前端目录

cd vue-admin-template

npm install

npm run build:prod

1
2
3
ps -aux |grep uwsgi
kill -9 3539 #最后这个号码是最上面那个
uwsgi --ini mywsgi.ini #再重启uwsgi就好了

前端问题解决·

Error:Rule can only have resource source(provided resource test include exclude【解决办法】 重装webpack

1
npm cache clean --force #清除缓存

npm install一定要保证全局的存储地址有充足的空间!!!(默认在C盘)

部署完成·

修改用户密码·

1
2
3
4
5
6
7
8
python3 manage.py shell
from django.contrib.auth import get_user_model
User = get_user_model()
user=User.objects.get(username='XXX')
user.set_password('new_password')
user.save()
或者
python3 manage.py changepassword username

连接远程服务器·

https://www.cnblogs.com/zhuminghui/p/10947930.html

自动部署·

生成公私钥·

1
ssh-keygen -o

将公钥放到仓库的公钥列表中,并将.git文件夹下的config文件中的url改为ssh地址