django-vue-admin 运行记录
1. 安装 ubuntu-20.04.6 桌面版
ubuntu-20.04.6-desktop-amd64.iso
桌面版本
桌面版的目的是 有浏览器可以看 django vue 的localhost网页。
用server版,需要用别的机器看,别的机器在权限上可能有问题。
sudo apt install vim -y
2. 设置 ssh
sudo apt-get update
sudo apt-get install openssh-server -y
sudo systemctl status ssh
sudo vim /etc/ssh/sshd_config 不用修改
sudo service ssh restart
ssh username@your_server_ip_address -p port_number
systemctl restart sshd
// 开启防火墙ssh的服务端口
ufw allow ssh
// 查看ssh服务状态
systemctl status ssh
// 关闭ssh服务
systemctl stop ssh
// 开启ssh服务
systemctl start ssh
// 重启ssh服务
systemctl restart ssh
// 设置开启自启
sudo systemctl enable ssh
// 关闭开机自启
sudo systemctl disable ssh
3. 桌面版设置固定ip地址
sudo apt install net-tools
ens33
cd /etc/netplan/
sudo vi /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
ethernets:
ens33:
dhcp4: no
addresses: [192.168.99.143/24]
optional: true
gateway4: 192.168.99.1
nameservers:
addresses: [114.114.114.114]
version: 2
renderer: NetworkManager
~
sudo netplan apply
4. server版本设置固定ip地址
cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
dhcp4: no
addresses: [192.168.99.57/24]
optional: true
gateway4: 192.168.99.1
nameservers:
addresses: [114.114.114.114]
version: 2
sudo netplan apply
5. 查看python版本
python3 -V
Python 3.8.10
sudo apt install python3-pip -y
6. 安装 mysql 8.0
sudo apt-get update
sudo apt install mysql-server -y
systemctl status mysql
netstat -an |grep 3306
mysqladmin --version
mysqladmin Ver 8.0.33-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
sudo apt-get install mysql-client
sudo systemctl start mysql.service
sudo systemctl restart mysql.service
sudo systemctl stop mysql.service
sudo systemctl enable mysql.service
sudo netstat -anp | grep mysql
sudo ufw allow 3306
sudo netstat -anp | grep mysql
netstat -ntulp | grep 3306
6.1 配置文件
sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/bak_mysqld.cnf
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
有的地方说是 只注释掉,好像是不行
sudo systemctl restart mysql
6.2 登录
mysql -h ip(本机) -uroot –p
mysql -hlocalhost -uroot –p
mysql -h 192.168.99.57 -uroot –p
mysql -h 127.0.0.1 -uroot –p
mysql -h127.0.0.1 -uroot –p
mysql -uroot -p
mysql -u root –p
6.3 远程访问
Ubuntu22.04.2安装&卸载MySQL8.0.33详细步骤
https://blog.csdn.net/m0_56349886/article/details/130751157
env.py
env.py
import os
from application.settings import BASE_DIR
# ================================================= #
# *************** mysql数据库 配置 *************** #
# ================================================= #
# 数据库 ENGINE ,默认演示使用 sqlite3 数据库,正式环境建议使用 mysql 数据库
# sqlite3 设置
#DATABASE_ENGINE = "django.db.backends.sqlite3"
#DATABASE_NAME = os.path.join(BASE_DIR, "db.sqlite3")
# 使用mysql时,改为此配置
DATABASE_ENGINE = "django.db.backends.mysql"
DATABASE_NAME = 'django-vue-admin' # mysql 时使用
# 数据库地址 改为自己数据库地址
DATABASE_HOST = "127.0.0.1"
# # 数据库端口
DATABASE_PORT = 3306
# # 数据库用户名
DATABASE_USER = "root"
# # 数据库密码
DATABASE_PASSWORD = "123456"
# 表前缀
TABLE_PREFIX = "dvadmin_"
# ================================================= #
# ******** redis配置,无redis 可不进行配置 ******** #
# ================================================= #
# REDIS_PASSWORD = ''
# REDIS_HOST = '127.0.0.1'
# REDIS_URL = f'redis://{REDIS_HOST}:6379'
# ================================================= #
# ****************** 功能 启停 ******************* #
# ================================================= #
DEBUG = True
# 启动登录详细概略获取(通过调用api获取ip详细地址。如果是内网,关闭即可)
ENABLE_LOGIN_ANALYSIS_LOG = True
# 登录接口 /api/token/ 是否需要验证码认证,用于测试,正式环境建议取消
LOGIN_NO_CAPTCHA_AUTH = True
# 是否启动API日志记录
API_LOG_ENABLE = locals().get("API_LOG_ENABLE", True)
# API 日志记录的请求方式
API_LOG_METHODS = locals().get("API_LOG_METHODS", ["POST", "UPDATE", "DELETE", "PUT"])
# API_LOG_METHODS = 'ALL' # ['POST', 'DELETE']
# ================================================= #
# ****************** 其他 配置 ******************* #
# ================================================= #
ENVIRONMENT = "test" # 环境,test 测试环境;prod线上环境;local本地环境
ALLOWED_HOSTS = ["*"]
# 系统配置存放位置:redis/memory(默认)
DISPATCH_DB_TYPE = 'redis'
ubuntu 20.04 ip 地址
创建数据库
django-vue-admin