Centos 7.5 python3.6

1. Overview of Django##

Django provides modules that are often used to develop websites. The common code is written for you. By reducing repetitive code, Django enables you to focus on interesting and key things in web applications. In order to achieve this goal, Django provides a high degree of abstraction of common web development models, provides quick solutions to frequently performed programming tasks, and provides clear conventions for "how to solve problems". Django's philosophy is DRY (Don't Repeat Yourself) to encourage rapid development!

Django Overall

urls.py
URL entry, linked to the corresponding views.A function (or generic class) in py corresponds to a function when accessing the URL.

views.py
Process user requests from urls.Corresponding in py,By rendering the web page in templates, the displayed content, such as the user name after logging in, and the data requested by the user, can be output to the web page.

models.py
Related to database operations, this is used when storing or reading data. Of course, you don't need to use it when you don't need the database.

forms.py
Form, the user enters the data on the browser to submit, the verification of the data and the generation of the input box, of course, you don’t need to use it.

templates folder
views.The function in py renders the Html template in templates to get dynamic content web pages. Of course, cache can be used to improve the speed.

admin.py
Backend, you can have a powerful backend with a small amount of code.

settings.py
Django settings, configuration files, such as DEBUG switch, location of static files, etc.

Two, system environment settings##

1、 Modify the system character set

echo 'LANG="en_GB.utf8"'>/etc/sysconfig/i18n && cat /etc/sysconfig/i18n

2、 Modify YUM source####

reference
Centos firewall & SELINUX shutdown and yum source configuration

Three, python installation##

1、 Install python related dependencies####

yum -y install openssl-devel readline-devel unzip gcc

2、 Download python source package

wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz

3、 Compile and install python

tar -xvf Python-3.6.1.tgz 
cd Python-3.6.1./configure --prefix=/usr/local/python36
make && make install

View installed tools####

$ ll /usr/local/python36/bin/
Total amount 24660
lrwxrwxrwx 1 root root 812 Dec 1215:36 2to3 -> 2to3-3.6-rwxr-xr-x 1 root root 110 Dec 1215:36 2to3-3.6-rwxr-xr-x 1 root root 25 112 December 1215:36 easy_install-3.6
lrwxrwxrwx 1 root root 712 Dec 1215:36 idle3 -> idle3.6-rwxr-xr-x 1 root root 108 Dec 1215:36 idle3.6-rwxr-xr-x 1 root root 223 1215:36 pip3
- rwxr-xr-x 1 root root 223 1215:36 pip3.6
lrwxrwxrwx 1 root root 812 Dec 1215:36 pydoc3 -> pydoc3.6-rwxr-xr-x 1 root root 93 Dec 1215:36 pydoc3.6
lrwxrwxrwx 1 root root 912 Dec 1215:36 python3 -> python3.6-rwxr-xr-x 2 root root 12603760 December 1215:35 python3.6
lrwxrwxrwx 1 root root 17 Dec 1215:36 python3.6-config -> python3.6m-config
- rwxr-xr-x 2 root root 12603760 December 1215:35 python3.6m
- rwxr-xr-x 1 root root 310612 December 1215:36 python3.6m-config
lrwxrwxrwx 1 root root 16 Dec 1215:36 python3-config -> python3.6-config
lrwxrwxrwx 1 root root 10 Dec 1215:36 pyvenv -> pyvenv-3.6-rwxr-xr-x 1 root root 450 Dec 1215:36 pyvenv-3.6-rwxr-xr-x 1 root root 230 Dec 1215:39 virtualenv

4、 Configure pip

vim /etc/pip.conf
[ global]
index-url = http://pypi.douban.com/simple/ 
trusted-host=pypi.douban.com
[ list]
format=columns

/usr/local/python36/bin/pip3 list
Package    Version
-----------------
pip        9.0.1  
setuptools 28.8.0

5、 Install virtualenv

/usr/local/python36/bin/pip3 install virtualenv

Results of the####

Collecting virtualenv
 Downloading http://pypi.doubanio.com/packages/6f/86/3dc328ee7b1a6419ebfac7896d882fba83c48e3561d22ddddf38294d3e83/virtualenv-15.1.0-py2.py3-none-any.whl(1.8MB)100%|████████████████████████████████|1.8MB 983kB/s 
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0

Fourth, install django

1、 Initialize the env environment####

Create a normal user

useradd devops
passwd devops

Switch to normal devops

su - devops
/usr/local/python36/bin/virtualenv ./python36env
Using base prefix '/usr/local/python36'
New python executable in/home/devops/python36env/bin/python3.6
Also creating executable in/home/devops/python36env/bin/python
Installing setuptools, pip, wheel...done.

Enter the virtual environment

source python36env/bin/activate(python36env)[devops@devops-python36 ~]$ pip list
Package    Version
-----------------
pip        9.0.1  
setuptools 38.2.4 
wheel      0.30.0

2、 django version selection####

Django 1.5.x supports Python 2.6.5 Python 2.7, Python 3.2 and 3.3.
Django 1.6.x supports Python 2.6.X,2.7.X,3.2.X and 3.3.X
Django 1.7.x supports Python 2.7,3.2,3.3,And 3.4 (Note: Python 2.6 is not supported)
Django 1.8.x supports Python 2.7,3.2,3.3,3.4 and 3.5.(Long-term support version LTS)
Django 1.9.x supports Python 2.7,3.4 and 3.5.Does not support 3.3 out
Django 1.10.x supports Python 2.7,3.4 and 3.5. 
Django 1.11.x supports Python 2.7,3.4,3.5 and 3.6 (Long-term support version LTS)The last one supports Python 2.Version 7
Django 2.0.x supports Python 3.4,3.5 and 3.6 (note that Python 2 is no longer supported)

3、 Install django

pip install "django>=1.11(python36env)[devops@devops-python36 ~]$ pip install "django>=1.11,<=1.12"
Collecting django<=1.12,>=1.11
 Downloading http://pypi.doubanio.com/packages/7e/36/5266e0c51ee9b953d60ea8ea1fea10e268b1368f9c0ad08e2ff76ee9c1b5/Django-1.11.8-py2.py3-none-any.whl(6.9MB)100%|████████████████████████████████|7.0MB 1.9MB/s 
Collecting pytz(from django<=1.12,>=1.11)
 Downloading http://pypi.doubanio.com/packages/a3/7f/e7d1acbd433b929168a4fb4182a2ff3c33653717195a26c1de099ad1ef29/pytz-2017.3-py2.py3-none-any.whl(511kB)100%|████████████████████████████████| 512kB 1.4MB/s 
Installing collected packages: pytz, django
Successfully installed django-1.11.8 pytz-2017.3

4、 mysql installation####

Database installation reference
Centos7.5 install mysql5.7.24 binary package deployment

5、 Install pip pymysql

( python36env)[devops@devops-python36 ~]$ pip install pymysql
Collecting pymysql
 Downloading http://pypi.doubanio.com/packages/c6/42/c54c280d8418039bd2f61284f99cb6d9e0eae80383fc72ceb6eac67855fe/PyMySQL-0.7.11-py2.py3-none-any.whl(78kB)100%|████████████████████████████████| 81kB 2.6MB/s 
Installing collected packages: pymysql
Successfully installed pymysql-0.7.11(python36env)[devops@devops-python36 ~]$ pip list
Package    Version
-----------------
Django     1.11.8 
pip        9.0.1  
PyMySQL    0.7.11 
pytz       2017.3 
setuptools 38.2.4 
wheel      0.30.0

Five, configure vim

yum -y install vim

vim ~/.vimrc
set tabstop=4set shiftwidth=4set softtabstop=4set expandtab
set fileformat=unix 
set nobomb
set ff=unix
set ambiwidth=double 
set fileencodings=utf-8,ucs-bom,cp936
syntax on
filetype plugin on 
set nocompatible
set completeopt=preview
set ai 
set hls
set nu

Recommended Posts

CentOS + Python3.6+
Centos 7.5 python3.6
CentOS7 upgrade python3
Python - centos6 installation
Centos7 install Python2.7
CentOS6.8 install python2.7
Centos 6.4 python 2.6 upgrade to 2.7
CentOS 8 (2)
Centos 6.4 python 2.6 upgrade to 2.7
Centos source installation Python3
CentOS 8 (1)
CentOS Python Java installations
Centos default python2.6 upgrade to
CentOS upgrade python2 to pyth
Centos 6.10 reinstall python and yum
CentOS7 install python3 and pip3
Centos6 install python3 pip3 ipython3
CentOS 6 compile and install python 3
Centos7 deploys python3 virtual environment
Python multithreading
Python FAQ
Python3 dictionary
Python3 module
python (you-get)
centos7 python3.7+vi
Python string
Python basics
Python descriptor
Python basics 2
Python exec
Python notes
Python3 tuple
Python advanced (1)
Python decorator
Python IO
CentOS + Jenkins
Python toolchain
Python multitasking-coroutine
Python overview
python introduction
CentOS quickly install Python3 and pip3
How to install Python 3.8 on CentOS 8
Python analytic
Python basics
Centos6.7 comes with python upgrade to
How to install Python on CentOS 8
Python basics 3
Python multitasking-threads
1.5 Install Centos7
Configure python3 environment on centos7 and
Python functions
python sys.stdout
python operator
Python entry-3
centos7_1708 installation
Install Python3 and Py under CentOS7
Python string
python queue Queue
CentOS7 repairs python to save yum
Python basics 4
Python basics 5