-
安裝包
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