将knight 传到linux上python
mysqldum -uroot -p --all-database > alldb.dump
在windows的cmd中执行上面命令导出mysql全部数据库的数据
而后将alldb.dump用xftp传到opt目录下mysql
导入数据:linux
mysql -uroot -p < alldb.dump
记得远程链接受权:
ios
mkvirtualenv knight
尝试云行下
nginx
发现缺乏模块。
解决步骤:sql
pip3 install django==1.11.16 pip3 install pymysql pip3 install django-multiselectfield
将项目的settings.py中参数改如下:
记得还需改变链接数据库的帐号密码等信息数据库
启动:
django
centos+django的项目部署就完成了vim
使用uwsgi.ini配置文件去启动项目,这个文件本身去建立便可,放哪均可以 (knight) [root@qishione knight]# cat uwsgi.ini [uwsgi] # Django-related settings # the base directory (full path) #写上项目的绝对路径 chdir= /opt/knight # Django's wsgi file #填写找到django的wsgi文件,填写相对路径,以chdir参数为相对路径 module= knight.wsgi # the virtualenv (full path) #填写虚拟环境的绝对路径 home= /root/Envs/knight/ # process-related settings # master #启动uwsgi主进程 master= true # maximum number of worker processes processes= 5 #若是你使用了nginx,作反向代理,必须填写socket连接,而不是http参数 # the socket (use the full path to be safe #socket= 0.0.0.0:8000 #若是你不用nginx,直接使用uwsgi,运行一个http服务端,就用这个http参数 http = 0.0.0.0:8000 # ... with appropriate permissions - may be needed # chmod-socket = 664 # clear environment on exit vacuum= true 指定配置文件去启动uwsgi uwsgi --ini uwsgi.ini
/opt/mydjangoproject/knight
启动你会发现静态文件不生效了windows
1.设置django的静态文件目录,收集一下 修改knight/settings.py ,写入以下参数 STATIC_ROOT= '/opt/static' 2.使用命令收集django的静态文件 python3 manage.py collectstatic 3.查看django的静态文件收集目录 ls /opt/static 4.配置nginx,反向代理,找到uwsgi项目,且配置nginx处理uwsgi的静态文件 nginx.conf 修改配置以下 server { listen 80; server_name qishijd.com; #只要用户访问qishijd.com:80/ 就走这个location匹配>,反向代理给uwsgi: location / { include uwsgi_params; uwsgi_pass 0.0.0.0:8000; } #当用户请求是qishijd.com/static/的时候 #就会进入这个location匹配 #经过alias参数进行路径别名,让nginx去/opt/static底下去找静>态资源 location /static { alias /opt/static; } }
记得改这里!!
10. 公司会用一个进程管理工具,去启动,管理多个项目,supervisor 原本咱们是用命令启动管理项目, 如今讲这些命令,写入到supervisor,经过superviosr去启动管理这些命令 使用python2的模块管理工具,去下载supervisor ,注意此时,退出虚拟环境 使用python2的模块管理工具,去下载supervisor ,注意此时,退出虚拟环境 使用python2的模块管理工具,去下载supervisor ,注意此时,退出虚拟环境 使用python2的模块管理工具,去下载supervisor ,注意此时,退出虚拟环境 使用python2的模块管理工具,去下载supervisor ,注意此时,退出虚拟环境 安装supervisor yum install python-setuptools #安装 easy_install supervisor 2.使用supervisor命令,生成配置文件 echo_supervisord_conf > /etc/supervisor.conf 3.在这个配置文件中,写入咱们想要管理的任务 vim /etc/supervisor.conf 在最底行写入以下配置 #定义一个任务,名字自定义 #commnad=参数,定义咱们启动项目的命令 [program:crm_knight] command=/root/Envs/knight/bin/uwsgi /opt/knight/uwsgi.ini stopasgroup=true ;默认为false,进程被杀死时,是否向这个 进程组发送stop信号,包括子进程 killasgroup=true ;默认为false,向进程组发送kill信号,包括子进程 4.经过配置文件启动supervisor服务 supervisord -c /etc/supervisor.conf 5.启动了supervisor服务端后,管理任务 supervisorctl -c /etc/supervisor.conf 任务管理命令以下:有两种,一个是交互式,一个是参数形式 #参数形式 supervisorctl -c /etc/supervisor.conf stop/start/restart all supervisorctl -c /etc/supervisor.conf start crm_knight #交互式形式 supervisorctl -c /etc/supervisor.conf