sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
而後更改源文件爲清華大學開源軟件鏡像站html
sudo vim /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
添加python3.6的倉庫python
sudo add-apt-repository ppa:jonathonf/python-3.6
更新源mysql
sudo apt-get update
更新安裝源後,輸入以下命令安裝Python3.6:nginx
sudo apt-get install -y python3.6
安裝完成以後,設置Python3.6的優先級,輸入以下命令:redis
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
下一步,咱們來更新pip,輸入以下代碼:sql
sudo apt-get install python3-pip sudo pip3 install --upgrade pip
至此,python升級完成django
輸入pip -Vubuntu
查看pip指向地址,是指向python3仍是python2vim
[global] index-url = http://mirrors.aliyun.com/pypi/simple trusted-host = mirrors.aliyun.com
pip install virtualenv --user
pip install virtualenvwrapper --user
查看virtualenvwrapper.sh位置bash
which virtualenvwrapper.sh
編輯~/.bashrc文件
sudo vim ~/.bashrc
export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/workspace source /usr/local/bin/virtualenvwrapper.sh(更換爲上面查到的位置)
而後執行
source ~/.bashrc
到這裏,虛擬環境也已經安裝好了
mkvirtualenv django_test -p python3
rmvirtualenv django_test
workon django_test
sudo apt-get install -y mysql-server sudo apt-get install -y libmysqlclient-dev
開啓mysql遠程訪問
http://www.javashuo.com/article/p-pmligeqk-hz.html
sudo apt-get install -y redis-server
sudo apt-get install -y nginx
pip install uwsgi
若是報錯,可嘗試下面的代碼
sudo apt-get install python3.6-dev