网站现在可以访问了:http://pys.phpvip.top:8000/json
遇到了一些问题,本地ok,放到服务器就各种出问题
一、启动服务时的ip 必须是0.0.0.0,否则无法访问,具体原因没有去查
二、错误信息:Invalid HTTP_HOST header: ‘xxx.xx.xxx.xxx:8000’. You may need to add ‘xxx.xx’ to ALLOWED_HOSTS
解决办法: 修改创建项目时生成的setting.py文件,将ALLOWED_HOSTS = []改为ALLOWED_HOSTS = ['*']
三、报错信息:TemplateDoesNotExist
解决办法,参考:https://blog.csdn.net/wjy397/article/details/48976137,原因是无法找到tempates文件夹,且要主要文件夹的名称大小写,虽然本地运行没问题;
四、日志记录的时间和linux系统时间不一致
Django在配置文件settings.py 中 默认配置 UTC世界标准时间,修改为:TIME_ZONE = 'Asia/Shanghai'
1、linux用netstat查看服务及监听端口,参考:https://www.runoob.com/linux/linux-comm-netstat.html
常用命令:netstat -antp
2、杀死进程:https://blog.csdn.net/dghggij/article/details/87621517
常用命令:kill 123