从零开始搭建CentOS+Python+nodejs开发环境

从零开始搭建CentOS+Python+nodejs开发环境

配置CentOS7的环境

yum源

  • 将yum源配置为阿里云镜像源:
1
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
1
2
3
4
5
6
7
8
#CentOS6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
# 或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
# CentOS7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  • 配置Epel源为阿里云镜像
1
2
3
4
5
6
7
8
9
# 备份
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
# CentOS7
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# CentOS6
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
# CentOS5
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
  • 更新yum源的缓存
1
2
yum clean all
yum makecache
  • 升级系统的软件
1
yum update -y

常用工具

1
yum install vim git net-tools git-lfs python-pip -y

安装Python

Pyenv与Python

  • 安装pyenv
1
2
3
4
5
6
7
# CheckOut Pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
# 将Pyenv写入环境变量
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
# 重新加载环境变量,使pyenv命令生效
source ~/.bash_profile
  • 安装python编译安装的依赖
1
yum install -y ncurses-libs zlib-devel mysql-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
  • 安装Python版本
1
2
3
4
pyenv install 3.7.4
# 如果下载太慢的话,可以使用下面的命令加速
v=3.7.4;wget http://npm.taobao.org/mirrors/python/$v/Python-$v.tar.xz -P ~/.pyenv/cache/;pyenv install $v
其中的数字是版本号

结果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
--2019-07-25 14:46:46--  http://npm.taobao.org/mirrors/python/3.7.4/Python-3.7.4.tar.xz
Resolving npm.taobao.org (npm.taobao.org)... 114.55.80.225
Connecting to npm.taobao.org (npm.taobao.org)|114.55.80.225|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://cdn.npm.taobao.org/dist/python/3.7.4/Python-3.7.4.tar.xz [following]
--2019-07-25 14:46:46-- http://cdn.npm.taobao.org/dist/python/3.7.4/Python-3.7.4.tar.xz
Resolving cdn.npm.taobao.org (cdn.npm.taobao.org)... 182.106.155.229, 110.80.139.242, 150.138.121.98, ...
Connecting to cdn.npm.taobao.org (cdn.npm.taobao.org)|182.106.155.229|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17131432 (16M) [application/x-xz]
Saving to: ‘/root/.pyenv/cache/Python-3.7.4.tar.xz.1’

100%[====================================>] 17,131,432 12.1MB/s in 1.4s

2019-07-25 14:46:47 (12.1 MB/s) - ‘/root/.pyenv/cache/Python-3.7.4.tar.xz.1’ saved [17131432/17131432]
Installing Python-3.7.4...
##---这个地方要等好久---#################
Installed Python-3.7.4 to /root/.pyenv/versions/3.7.4
# ^----------出现Installed说明安装完成

virtualenv

升级pip

1
pip install pip --upgrade

安装virtualenv

1
pip install virtualenv

创建虚拟环境

1
2
# p参数为虚拟环境的目标版本, Virtualenv Name 为虚拟环境的名称
virtualenv -p ~/.pyenv/versions/3.7.4/bin/python [Virtualenv Name]

修改pip源为阿里云源

1
2
3
4
5
6
mkdir ~/.pip
cat << EOF > ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
EOF

安装NodeJS

安装nvm

–>NVM文档

1
2
3
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
# 或者
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

如果完成后没有nvm命令的话,还需要执行:

1
2
export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

安装最新稳定版的NodeJS

1
nvm install node

验证是否安装成功

1
2
node -v
# v12.7.0

安装nrm

1
npm install -g nrm

或者使用CNPM

1
npm install -g cnpm --registry=https://registry.npm.taobao.org

评论

Agile Angularjs Animation Application Artificial Intelligence BP Babel Bokeh Book C4.5 CART CD CLI CSS CentOS Cinder Clipboardjs Concept Continuous Delivery DeepLearning Department DevOps Develop Development Directive Distribution Django Document ES5 ES6 Echarts Engine Entropy Filter Front End Gallery Git Gradient descent Hexo Horizon ID3.5 Icarus JavaScript Javascript KVM LaTeX LibreOffice Linux MNIST Machine Learning Matrix MiddleWare Module Native Network Nginx NodeJS OOP OpenSSH OpenStack OpenStackApi Operations Oprations PDF Pipline Probability Python React Relational algebra Restful Route SVD SVM Scalar Sigmoid Team Tempest Tensor TensorFlow Testing Time TimeMachine Tips Vector Vmware Vue Vuex WSGI Web Word Cut aliyun auth babel certbot decision tree eject git homebrew jwt keystone loader mathematics migrate openstack outline pdf2html pm2 singular value decomposition stylus vue-router vue-ssr webpack 事件 事件代理 事件冒泡 事件捕获 低通滤波器 入门 全局变量 全局对象 全栈 公式 决策树 函数 分类器 加速 匹配滤波边缘检测 卷积 卷积核 原型链 双向绑定 反向传播 发布 变量类型 官方示例 对偶形式 对象 平移和查分边缘检测 思维导图 感知机模型 拉格朗日乘子法 推导 提交阶段 数据绑定 最大似然估计 最小二乘估计 最小二乘法 本地 朴素贝叶斯 机器学习 条件概率 梯度下降 梯度方向边缘检测 概念 概率 求导 流程 源码 源码阅读 生命周期 矩阵 神经网络 私有对象 线性回归 联合概率 脚手架 识别 调试 贝叶斯判定准则 边缘检测 边际概率 闭包 间隔 高斯分布 高通滤波器
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×