腾讯云服务器配置

腾讯云服务器配置(Ubuntu16.04)

1.首先备份apt更新源文件

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

2.升级python到python3.6.8

添加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

3.修改PIP安装源

[global]
index-url = http://mirrors.aliyun.com/pypi/simple
trusted-host = mirrors.aliyun.com

4.安装虚拟环境

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

5.安装mysql

sudo apt-get install -y mysql-server
sudo apt-get install -y libmysqlclient-dev

开启mysql远程访问

http://www.javashuo.com/article/p-pmligeqk-hz.html

6.安装redis

sudo apt-get install -y redis-server

7.安装nginx

sudo apt-get install -y nginx

8.安装uwsgi

pip install uwsgi

若是报错,可尝试下面的代码

sudo apt-get install python3.6-dev
相关文章
相关标签/搜索