ubuntu系统django项目部署

  1. 安装包
    sudo apt update

    apt install mysql-server mysql-client

  2. 设置远程访问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; 
  3. 修改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)
  4. 修改首页的启动地址
    修改工程目录中的url ,并修改url(r’^$’, views.home)

  5. 安装pip3
    apt install python3-pip

  6. 安装必备库——–需要在项目文件下安装
    apt install openssl
    pip3 install django==1.11
    pip3 install pymysql
    pip3 install Pillow # module PIL

  7. 查看进程
    netstat -lntp

    • check setting file for mysql password in django!
  8. 启动项目
    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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值