此专题是幕课网上的一个实战的笔记
https://coding.imooc.com/class/78.html
部署项目:ubuntu
开发环境:Mac OS (可选用windows)
使用ssh 连接ubuntu进行项目配置,PyCharm在Mac OS中进行远程开发调试
参考网址:
Django在线教育平台搭建
一、PyCharm、Navicat、Mysql、Python的安装
Mysql、Python(安装在ubuntu)
PyCharm、Navicat(安装在Mac OS)
mysql必须记住安装密码
二、virtualenv的安装和配置(ubuntu)
1. To install Python’s virtual environment:
sudo pip3 install virtualenv
2. Create a virtual environment in Python 3 with the environment name of testvir2:
virtualenv -p python3 testvir2
3. Activate the newly created virtual environment :
source testvir2/bin/activate
4. To deactivate an active virtual environment:
deactivate
5. activate virtual environment
source testvir2/bin/activate
6. install django
pip install django==1.9.8
7. cd into any dir, create project dir in virtual environment
三、PyCharm和Navicat的简单使用
1. 配置PyCharm在远程虚拟环境(virtualenv)调试、运行程序
use PyCharm in virtualenv
a. Configure -> Preferences -> Project Interpreter
b. Add Remote ->
“SSH Credentials”
Host: 192.168.251.88
Port: 22
User name: benzhong
Auth type: Password
Password, Save password
Python interpreter path: /home/benzhong/Study/virtualenv/testvir2/bin/python3.5
(the activate virtualenv path, python3.5)
2. Install Django in virtual environment
source testvir2/bin/activate
pip install django==1.9.8
3. Create Django project
"Django"
Interpreter: remote virtualenv interpreter
4. 设置通过IP地址访问(默认情况下只允许本地IP地址访问),通过另外一台服务器访问
use other server's browser
Run -> Edit Configurations...
Host: 0.0.0.0
监听"0.0.0.0"的IP
5. 解决PyCharm不能智能提示:
设置不同目录的功能
”templates“ -> "Mark Directory As" -> "Source Root"