-
安装包
sudo apt update
apt install mysql-server mysql-client
-
设置远程访问mysql
a) 查找 mysql.conf
find / -name mysql.cnf
b)注释mysql.cof文件的bind_address ——– vim /etc/mysql/mysql.conf.d/mysqld.cnf
/etc/mysql/mysql.conf.d
c)mysql -u root -p
d) this allow the user from remote ip to connect ot the mysql: GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; flush privileges;
-
修改django的配置文件
a)修改settings.py文件中的DEBUG=FALSE,ALLOWED_HOST=[‘*’]
b)修改urls.py
b1)from django.views.static import serve url中加入以下配置 url(r'^static/(?P<path>.*)$', serve, {"document_root": settings.STATIC_ROOT}), url(r'^media/(?P<path>.*)$', serve, {"document_root": settings.MEDIA_ROOT}), b2)setting中 STATIC_ROOT = os.path.join(BASE_DIR, 'static') b3)url中修改首页访问的地址 url(r'^$', views.home)
-
修改首页的启动地址
修改工程目录中的url ,并修改url(r’^$’, views.home)
-
安装pip3
apt install python3-pip
-
安装必备库——–需要在项目文件下安装
apt install openssl
pip3 install django==1.11
pip3 install pymysql
pip3 install Pillow # module PIL
-
查看进程
netstat -lntp
- check setting file for mysql password in django!
-
启动项目
python3 manage.py runserver
127.0.0.1 is localhost 0.0.0.0 is every ip
127.0.0.1 on your comuter is only your computer
127.0.0.1 on server is only the serverser