安装python3
mkdir /usr/local/python3/
cd /usr/local/python3/
wget https://www.python.org/ftp/python/3.11.6/Python-3.11.6.tgz
106 ./configure --with-ssl
107 make
108 make install
ln -s /usr/local/python3/Python-3.11.6/python /usr/bin/python3
[root@bogon Python-3.11.6]# cat /root/.pip/pip.conf
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
mariadb安装
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'wangfei'@'%' WITH GRANT OPTION;
ERROR 1133 (28000): Can't find any matching row in the user table
MariaDB [mysql]> CREATE USER 'wangfei'@'%' IDENTIFIED BY 'rootroot';
Query OK, 0 rows affected (0.001 sec)
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'wangfei'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.000 sec)
pip3 install django==3.0.3
[root@bogon wangdalei]# python3 manage.py createsuperuser
Username (leave blank to use 'root'): admin
Email address:
Password:
Password (again):
Superuser created successfully.
访问后台
http://172.31.7.188:8000/admin/
setting配置数据库
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'dj',
'USER': 'root',
'PASSWORD': 'rootroot',
'HOST': '127.0.0.1',
'PORT': '3306',
'charset': 'utf8mb4',
}
}
LANGUAGE_CODE = 'zh-hans'