标签:eset 用户登录 and profile ini 编译器 环境 word serve
安装python3.6.4
#安装依赖包 yum install openssl-devel readline-devel unzip -y #编译安装 tar xf Python-3.6.4.tgz cd Python-3.6.4 ./configure --prefix=/usr/local/python36 --enable-optimizations make && make install #配置环境 vim /etc/profile.d/py3.sh export PATH=$PATH:/usr/local/python36/bin source /etc/profile.d/py3.sh
安装virtualenvwrapper
/usr/local/python36/bin/pip3 install virtualenvwrapper #在varant账号下编辑 $ vim .bashrc ... VIRTUALENVWRAPPER_PYTHON=/usr/local/python36/bin/python3 if [ -f /usr/local/python36/bin/virtualenvwrapper.sh ]; then export WORKON_HOME=$HOME/.virtualenvs source /usr/local/python36/bin/virtualenvwrapper.sh fi
创建虚拟环境
mkvirtualenv --python="/usr/local/python36/bin/python3" devops_env #在虚拟环境中安装常用工具 pip install ipython pip install requests
安装mariadb
yum install -y mariadb mariadb-server mariadb-devel #在[mysqld]下新增以下内容 default-storage-engine =innodb innodb_file_per_table = 1 collation-server = utf8_general_ci init-connect = ‘SET NAMES utf8‘ character-set-server = utf8 #启动mariadb并设置开机启动 sudo systemctl start mariadb sudo systemctl enable mariadb #初始化 mysql_secure_installation #创建数据库 create database devops CHARACTER SET utf8;
准备django环境
# 进入虚拟环境 workon devops #安装django pip install "django >1.11, <2.0" #安装mysqlclient pip install mysqlclient #创建django项目 (devops) heboan@heboan-PC:~$ mkdir app (devops) heboan@heboan-PC:~$ cd app (devops) heboan@heboan-PC:~/app$ django-admin startproject devops #使用pycharm打开devops项目,并配置编译器为虚拟环境devops #配置dajngo连接mariadb, settings.py ... DATABASES = { ‘default‘: { ‘ENGINE‘: ‘django.db.backends.mysql‘, ‘NAME‘: ‘devops‘, ‘USER‘: ‘root‘, ‘PASSWORD‘: ‘root‘, ‘HOST‘: ‘127.0.0.1‘, ‘PORT‘: 3306, ‘OPTIONS‘: { ‘init_command‘: ‘SET default_storage_engine=INNODB;‘, }, } } #配置语言和时区 LANGUAGE_CODE = ‘zh-hans‘ TIME_ZONE = ‘Asia/Shanghai‘ USE_I18N = True USE_L10N = True USE_TZ = False # 配置django项目的运行 在pycharm中点击manage.py运行一次 Run -->Edit Configurations Script parameters: runserver 0.0.0.0:8000
后期的开发中,我们会根据不同的功能模块创建app,为了维护方便,我们在项目目录下创建Python package命名为apps, 以后所有创建的app都放在apps下
右键apps, Mark Directory as Sources Root
编辑setting.py
sys.path.index(0, os.path.join(BASE_DIR, ‘apps‘))
安装reset framework
pip install djangorestframework
pip install markdown
pip install django-filter
Add ‘rest_framework‘
to your INSTALLED_APPS
setting.
INSTALLED_APPS = ( ... ‘rest_framework‘, )
标签:eset 用户登录 and profile ini 编译器 环境 word serve
原文地址:https://www.cnblogs.com/sellsa/p/10265734.html