Environmental installation
Foreplay
Basic knowledge needed:
- Network configuration: Reference resources
- Share path: Reference resources
Required software & Image
- VirtualBox: the best free virtual machine software
The download address is as follows (install the software suitable for your own operating system): https://www.virtualbox.org/wiki/Downloads
- Vagrant: that's the tool we need to create and manage virtual machines
The download address is as follows (install the software suitable for your own operating system): http://downloads.vagrantup.com/
- System image: it is provided to vagrant to create (I understand this is special, because the suffix after file download is. box instead of. iso)
http://www.vagrantbox.es/ Select a system image that you want, for example, I use CentOS 7.2 pure version, and then I can download it from Xunlei or direct browser at the following address https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.2/vagrant-centos-7.2.box
Environmental preparation
Install these two programs under windows:
vagrant
virtualbox
Directory preparation
- Software installation path
- Development environment configuration path
D:\>cd study D:\study>cd devops-8 D:\study\devops-8>cd data D:\study\devops-8\data>vagrant box list centos7-dev (virtualbox, 0) centosbox (virtualbox, 0) D:\study\devops-8\data>vagrant init centos7-dev #Initialize the environment path and generate the Vagrantfile configuration file
Modify the Vagrantfile configuration file
#Change port mapping to 8000 config.vm.network "forwarded_port", guest: 80, host: 8000
Start virtual machine
D:\study\devops-8\data>vagrant up Image exists in: C:\Users\wanghui\.vagrant.d\boxes\centos7-dev\0
Login virtual machine
user:vagrant pass:vagrant host:127.0.0.1 port:2222
Synchronous directory
==> default: Mounting shared folders... default: /vagrant => D:/study/devops-8/data
Software installation
django support version: 1.11
time synchronization
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ,Time zone setting; timedatectl status ,Check the time synchronization status; yum install ntp -y timedatectl set-ntp true ,Turn on network time synchronization;
Configure yum
yum -y install gcc gcc-c++ openssl openssl-devel vim net-tools wget zip unzip lrzsz mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
Install Python
yum -y install openssl-devel readline-devel unzip #Solution dependence wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz tar xf Python3.6.6.tgz cd Pyrthon3.6.6 # configure ./configure --enable-optimizations # vim Modules/Setup release the following configuration _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto #install make altinstall
Modify pip configuration
# tee /etc/pip.conf <<EOF [global] index-url = http://pypi.douban.com/simple trusted-host = pypi.douban.com [list] format=columns EOF
Install virtualenv and initialize the environment
pip3.6 install virtualenv su - vagrant cd /home/vagrant virtualenv -p /usrlocal/bin/python3.6 venv3 source venv3/bin/activite pip3 install "django>=1.11,<2.0"
Install & configure database
yum -y install mariadb mariadb-server mariadb-devel # vim /etc/my.cnf configuration [mysqld] port = 3306 default-storage-engine = innodb innodb_file_per_table collation-server = utf8_general_ci init-connect = 'SET NAMES utf8' character-set-server = utf8 [mysql] default-character-set=utf8 -----Service startup----- systemctl start mariadb systemctl enable mariadb -----Initialize configuration----- mysql_secure_installation #Password set to 123456 ------install python-mysql Plug-in unit------ [vagrant@localhost ~]$ source /home/vagrant/venv3/bin/activate pip3 install mysqlclient ------Create database------- mysql -uroot -p123456 -e "create database devops CHARACTER SET utf8;"
- Django database configuration
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'django', 'USER': 'root', 'PASSWORD': '123456', 'HOST': '127.0.0.1', 'PORT': 3306, 'OPTIONS':{ 'init_command': 'SET default_storage_engine=INNODB;', }, } }