腾讯云服务器配置
腾讯云服务器配置(Ubuntu16.04)
1.首先备份apt更新源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
然后更改源文件为清华大学开源软件镜像站,阿里云开源镜像站
sudo vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
更新源
sudo apt-get update
下一步,我们来更新pip,输入如下代码:
sudo apt-get install python3-pip sudo pip3 install --upgrade pip
至此,python升级完成
输入pip -V
查看pip指向地址,是指向python3还是python2
3.修改PIP安装源
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
4.安装虚拟环境
pip install virtualenv
pip install virtualenvwrapper
查看virtualenvwrapper.sh位置
sudo find / -name 'virtualenvwrapper.sh'
编辑~/.bashrc文件
sudo vim ~/.bashrc
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=$HOME/.local/bin/virtualenv
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/workspace
source $HOME/.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远程访问
https://www.cnblogs.com/linjiqin/p/5270938.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