CentOS 6.x安裝django

1 系統環境

1、系統版本:
[root@localhost ~]# cat /etc/redhat-release 
CentOS release 6.7 (Final)
2、內核版本:
[root@localhost ~]# uname -r
2.6.32-573.el6.x86_64
3、Python版本:
[root@localhost ~]# python -V
Python 2.6.6

2 升級Python

由於2.6版本的Python不支持高版本的Django,所以要編譯升級系統默認的Python。
2.1 安裝Python依賴包

安裝常用系統工具包:
[root@localhost ~]# yum -y install vim gcc gcc-c++ mlocate wget zip unzip xz
安裝Python依賴包:
[root@localhost ~]# yum -y install readline-devel tk-devel tcl-devel openssl-devel sqlite-devel zlib-devel

2.2 下載Python源碼包以及工具包:

[root@localhost ~]# wget "https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz"
[root@localhost ~]# wget "https://pypi.python.org/packages/a9/23/720c7558ba6ad3e0f5ad01e0d6ea2288b486da32f053c73e259f7c392042/setuptools-36.0.1.zip"
[root@localhost ~]# wget "https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz"

2.3 編譯安裝Python源碼包以及工具包:

[root@localhost ~]# tar zxvf Python-2.7.13.tgz
[root@localhost ~]# cd Python-2.7.13 && ./configure && make all && make install && cd ..
[root@localhost ~]# unzip setuptools-36.0.1.zip
[root@localhost ~]# cd setuptools-36.0.1 && python setup.py install && cd ..
[root@localhost ~]# tar zxvf pip-9.0.1.tar.gz
[root@localhost ~]# cd pip-9.0.1 && python setup.py install && cd ..

2.4 檢查安裝的Python,setuptools,pip版本是否正常:

[root@localhost ~]# python -V
Python 2.7.13
[root@localhost ~]# easy_install --version
setuptools 36.0.1 from /usr/local/lib/python2.7/site-packages/setuptools-36.0.1-py2.7.egg (Python 2.7)
[root@localhost ~]# pip --version
pip 9.0.1 from /usr/local/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)

注意檢查編譯安裝的setuptools和pip是否正確的安裝到了Python2.7的第三方模塊目錄下,如果沒有則需要重新進行編譯安裝。

3 安裝Django

3.1 使用pip安裝默認最新穩定版的Django:

[root@localhost ~]# pip install Django

3.2 使用pip安裝指定版本的Django:

[root@localhost ~]# pip install Django==1.8.11

3.3 Django的Github地址:

你也可以到下方的github倉庫中查看你所需要的Django版本
https://github.com/django/django/releases

或者到Django的官方網站中查看詳細信息
https://www.djangoproject.com/
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章